00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 char sh_pvect_r_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_pois_vect_r/sh_pvect_r.C,v 1.3 2004/12/23 16:00:10 j_novak Exp $" ;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #include <stdlib.h>
00050 #include <math.h>
00051
00052 #include "matrice.h"
00053 #include "type_parite.h"
00054 #include "proto.h"
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 Tbl _sh_pvect_r_pas_prevu (int, int, double) ;
00083 Tbl _sh_pvect_r_cheb (int, int, double) ;
00084 Tbl _sh_pvect_r_chebp (int, int, double) ;
00085 Tbl _sh_pvect_r_chebi (int, int, double) ;
00086 Tbl _sh_pvect_r_chebu (int, int, double) ;
00087
00088
00089
00090
00091 Tbl _sh_pvect_r_pas_prevu (int n, int l, double echelle) {
00092
00093 cout << " Solution homogene pas prevue ..... : "<< endl ;
00094 cout << " N : " << n << endl ;
00095 cout << " l : " << l << endl ;
00096 cout << " echelle : " << echelle << endl ;
00097 abort() ;
00098 exit(-1) ;
00099 Tbl res(1) ;
00100 return res;
00101 }
00102
00103
00104
00105
00106
00107
00108 Tbl _sh_pvect_r_cheb (int n, int l, double echelle) {
00109
00110 const int nmax = 200 ;
00111 static Tbl* tab[nmax] ;
00112 static int nb_dejafait = 0 ;
00113 static int l_dejafait[nmax] ;
00114 static int nr_dejafait[nmax] ;
00115 static double vieux_echelle = 0;
00116
00117
00118 if (vieux_echelle != echelle) {
00119 for (int i=0 ; i<nb_dejafait ; i++) {
00120 l_dejafait[i] = -1 ;
00121 nr_dejafait[i] = -1 ;
00122 delete tab[i] ;
00123 }
00124 nb_dejafait = 0 ;
00125 vieux_echelle = echelle ;
00126 }
00127
00128 int indice = -1 ;
00129
00130
00131 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00132 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00133 indice = conte ;
00134
00135
00136 if (indice == -1) {
00137 if (nb_dejafait >= nmax) {
00138 cout << "_sh_pvect_r_cheb : trop de Tbl" << endl ;
00139 abort() ;
00140 exit (-1) ;
00141 }
00142
00143
00144 l_dejafait[nb_dejafait] = l ;
00145 nr_dejafait[nb_dejafait] = n ;
00146
00147
00148
00149 Tbl res(2, n) ;
00150 res.set_etat_qcq() ;
00151 double* coloc = new double[n] ;
00152
00153 int * deg = new int[3] ;
00154 deg[0] = 1 ;
00155 deg[1] = 1 ;
00156 deg[2] = n ;
00157
00158
00159
00160
00161 if (l==0) {
00162 for (int i=0 ; i<n ; i++)
00163 coloc[i] = echelle - cos(M_PI*i/(n-1)) ;
00164
00165 cfrcheb(deg, deg, coloc, deg, coloc) ;
00166 for (int i=0 ; i<n ;i++)
00167 res.set(0, i) = coloc[i] ;
00168 }
00169 else if (l==1) {
00170 res.set(0, 0) = 1 ;
00171 for (int i=1 ; i<n ; i++)
00172 res.set(0, i) = 0 ;
00173 }
00174 else {
00175
00176 for (int i=0 ; i<n ; i++)
00177 coloc[i] = pow(echelle-cos(M_PI*i/(n-1)), double(l-1)) ;
00178
00179 cfrcheb(deg, deg, coloc, deg, coloc) ;
00180 for (int i=0 ; i<n ;i++)
00181 res.set(0, i) = coloc[i] ;
00182 }
00183
00184
00185
00186
00187 for (int i=0 ; i<n ; i++)
00188 coloc[i] = 1/pow(echelle-cos(M_PI*i/(n-1)), double(l+2)) ;
00189
00190 cfrcheb(deg, deg, coloc, deg, coloc) ;
00191 for (int i=0 ; i<n ;i++)
00192 res.set(1, i) = coloc[i] ;
00193
00194 delete [] coloc ;
00195 delete [] deg ;
00196 tab[nb_dejafait] = new Tbl(res) ;
00197 nb_dejafait ++ ;
00198 return res ;
00199 }
00200
00201 else return *tab[indice] ;
00202 }
00203
00204
00205
00206
00207
00208 Tbl _sh_pvect_r_chebp (int n, int l, double) {
00209
00210 const int nmax = 200 ;
00211 static Tbl* tab[nmax] ;
00212 static int nb_dejafait = 0 ;
00213 static int l_dejafait[nmax] ;
00214 static int nr_dejafait[nmax] ;
00215
00216 int indice = -1 ;
00217
00218
00219 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00220 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00221 indice = conte ;
00222
00223
00224 if (indice == -1) {
00225 if (nb_dejafait >= nmax) {
00226 cout << "_sh_pvect_r_chebp : trop de Tbl" << endl ;
00227 abort() ;
00228 exit (-1) ;
00229 }
00230
00231
00232 l_dejafait[nb_dejafait] = l ;
00233 nr_dejafait[nb_dejafait] = n ;
00234
00235 Tbl res(n) ;
00236 res.set_etat_qcq() ;
00237 double* coloc = new double[n] ;
00238
00239 int * deg = new int[3] ;
00240 deg[0] = 1 ;
00241 deg[1] = 1 ;
00242 deg[2] = n ;
00243
00244 assert (div(l, 2).rem == 1) ;
00245 if (l==1) {
00246 res.set(0) = 1 ;
00247 for (int i=1 ; i<n ; i++)
00248 res.set(i) = 0 ;
00249 }
00250 else {
00251 for (int i=0 ; i<n ; i++)
00252 coloc[i] = pow(sin(M_PI*i/2/(n-1)), double(l-1)) ;
00253
00254 cfrchebp(deg, deg, coloc, deg, coloc) ;
00255 for (int i=0 ; i<n ;i++)
00256 res.set(i) = coloc[i] ;
00257 }
00258
00259 delete [] coloc ;
00260 delete [] deg ;
00261 tab[nb_dejafait] = new Tbl(res) ;
00262 nb_dejafait ++ ;
00263 return res ;
00264 }
00265
00266 else return *tab[indice] ;
00267 }
00268
00269
00270
00271
00272
00273
00274 Tbl _sh_pvect_r_chebi (int n, int l, double) {
00275
00276 const int nmax = 200 ;
00277 static Tbl* tab[nmax] ;
00278 static int nb_dejafait = 0 ;
00279 static int l_dejafait[nmax] ;
00280 static int nr_dejafait[nmax] ;
00281
00282 int indice = -1 ;
00283
00284
00285 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00286 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00287 indice = conte ;
00288
00289
00290 if (indice == -1) {
00291 if (nb_dejafait >= nmax) {
00292 cout << "_sh_pvect_r_chebi : trop de Tbl" << endl ;
00293 abort() ;
00294 exit (-1) ;
00295 }
00296
00297
00298 l_dejafait[nb_dejafait] = l ;
00299 nr_dejafait[nb_dejafait] = n ;
00300
00301
00302 assert (div(l, 2).rem == 0) ;
00303
00304
00305 Tbl res(n) ;
00306 res.set_etat_qcq() ;
00307 double* coloc = new double[n] ;
00308
00309 int * deg = new int[3] ;
00310 deg[0] = 1 ;
00311 deg[1] = 1 ;
00312 deg[2] = n ;
00313
00314 if (l==0) {
00315 res.set(0) = 1 ;
00316 for (int i=1 ; i<n ; i++)
00317 res.set(i) = 0 ;
00318 }
00319 else {
00320 for (int i=0 ; i<n ; i++)
00321 coloc[i] = pow(sin(M_PI*i/2/(n-1)), double(l-1)) ;
00322
00323 cfrchebi(deg, deg, coloc, deg, coloc) ;
00324 for (int i=0 ; i<n ;i++)
00325 res.set(i) = coloc[i] ;
00326 }
00327
00328 delete [] coloc ;
00329 delete [] deg ;
00330 tab[nb_dejafait] = new Tbl(res) ;
00331 nb_dejafait ++ ;
00332 return res ;
00333 }
00334
00335 else return *tab[indice] ;
00336 }
00337
00338
00339
00340
00341
00342
00343
00344 Tbl _sh_pvect_r_chebu (int n, int l, double) {
00345
00346 const int nmax = 200 ;
00347 static Tbl* tab[nmax] ;
00348 static int nb_dejafait = 0 ;
00349 static int l_dejafait[nmax] ;
00350 static int nr_dejafait[nmax] ;
00351
00352 int indice = -1 ;
00353
00354
00355 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00356 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00357 indice = conte ;
00358
00359
00360 if (indice == -1) {
00361 if (nb_dejafait >= nmax) {
00362 cout << "_sh_pvect_r_chebu : trop de Tbl" << endl ;
00363 abort() ;
00364 exit (-1) ;
00365 }
00366
00367
00368 l_dejafait[nb_dejafait] = l ;
00369 nr_dejafait[nb_dejafait] = n ;
00370
00371
00372
00373 Tbl res(n) ;
00374 res.set_etat_qcq() ;
00375 double* coloc = new double[n] ;
00376
00377 int * deg = new int[3] ;
00378 deg[0] = 1 ;
00379 deg[1] = 1 ;
00380 deg[2] = n ;
00381
00382 for (int i=0 ; i<n ; i++)
00383 coloc[i] = pow(-1-cos(M_PI*i/(n-1)), double(l+2)) ;
00384
00385 cfrcheb(deg, deg, coloc, deg, coloc) ;
00386 for (int i=0 ; i<n ;i++)
00387 res.set(i) = coloc[i] ;
00388
00389 delete [] coloc ;
00390 delete [] deg ;
00391 tab[nb_dejafait] = new Tbl(res) ;
00392 nb_dejafait ++ ;
00393 return res ;
00394 }
00395
00396 else return *tab[indice] ;
00397 }
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407 Tbl sh_pvect_r(int n, int l, double echelle, int base_r) {
00408
00409
00410 static Tbl (*sh_pvect_r[MAX_BASE])(int, int, double) ;
00411 static int nap = 0 ;
00412
00413
00414 if (nap==0) {
00415 nap = 1 ;
00416 for (int i=0 ; i<MAX_BASE ; i++) {
00417 sh_pvect_r[i] = _sh_pvect_r_pas_prevu ;
00418 }
00419
00420 sh_pvect_r[R_CHEB >> TRA_R] = _sh_pvect_r_cheb ;
00421 sh_pvect_r[R_CHEBU >> TRA_R] = _sh_pvect_r_chebu ;
00422 sh_pvect_r[R_CHEBP >> TRA_R] = _sh_pvect_r_chebp ;
00423 sh_pvect_r[R_CHEBI >> TRA_R] = _sh_pvect_r_chebi ;
00424 }
00425
00426 Tbl res(sh_pvect_r[base_r](n, l, echelle)) ;
00427 return res ;
00428 }