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