00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 char solh_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/solh.C,v 1.8 2008/02/18 13:53:43 j_novak Exp $" ;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
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
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 #include <stdio.h>
00102 #include <stdlib.h>
00103 #include <math.h>
00104
00105 #include "proto.h"
00106 #include "matrice.h"
00107 #include "type_parite.h"
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 Tbl _solh_pas_prevu (int n, int l, double echelle) {
00133
00134 cout << " Solution homogene pas prevue ..... : "<< endl ;
00135 cout << " N : " << n << endl ;
00136 cout << " l : " << l << endl ;
00137 cout << " echelle : " << echelle << endl ;
00138 abort() ;
00139 exit(-1) ;
00140 Tbl res(1) ;
00141 return res;
00142 }
00143
00144
00145
00146
00147
00148
00149 Tbl _solh_r_cheb (int n, int l, double echelle) {
00150
00151 const int nmax = 200 ;
00152 static Tbl* tab[nmax] ;
00153 static int nb_dejafait = 0 ;
00154 static int l_dejafait[nmax] ;
00155 static int nr_dejafait[nmax] ;
00156 static double vieux_echelle = 0;
00157
00158
00159 if (vieux_echelle != echelle) {
00160 for (int i=0 ; i<nb_dejafait ; i++) {
00161 l_dejafait[i] = -1 ;
00162 nr_dejafait[i] = -1 ;
00163 delete tab[i] ;
00164 }
00165 nb_dejafait = 0 ;
00166 vieux_echelle = echelle ;
00167 }
00168
00169 int indice = -1 ;
00170
00171
00172 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00173 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00174 indice = conte ;
00175
00176
00177 if (indice == -1) {
00178 if (nb_dejafait >= nmax) {
00179 cout << "_solh_r_cheb : trop de Tbl" << endl ;
00180 abort() ;
00181 exit (-1) ;
00182 }
00183
00184
00185 l_dejafait[nb_dejafait] = l ;
00186 nr_dejafait[nb_dejafait] = n ;
00187
00188
00189
00190 tab[nb_dejafait] = new Tbl(2, n) ;
00191 Tbl* pres = tab[nb_dejafait] ;
00192 pres->set_etat_qcq() ;
00193 double* coloc = new double[n] ;
00194
00195 int * deg = new int[3] ;
00196 deg[0] = 1 ;
00197 deg[1] = 1 ;
00198 deg[2] = n ;
00199
00200
00201
00202
00203 if (l==0) {
00204 pres->set(0, 0) = 1 ;
00205 for (int i=1 ; i<n ; i++)
00206 pres->set(0, i) = 0 ;
00207 }
00208 else {
00209 for (int i=0 ; i<n ; i++)
00210 coloc[i] = pow(echelle-cos(M_PI*i/(n-1)), double(l)) ;
00211
00212 cfrcheb(deg, deg, coloc, deg, coloc) ;
00213 for (int i=0 ; i<n ;i++)
00214 pres->set(0, i) = coloc[i] ;
00215 }
00216
00217
00218
00219
00220 for (int i=0 ; i<n ; i++)
00221 coloc[i] = 1/pow(echelle-cos(M_PI*i/(n-1)), double(l+1)) ;
00222
00223 cfrcheb(deg, deg, coloc, deg, coloc) ;
00224 for (int i=0 ; i<n ;i++)
00225 pres->set(1, i) = coloc[i] ;
00226
00227
00228 delete [] coloc ;
00229 delete [] deg ;
00230 indice = nb_dejafait ;
00231 nb_dejafait ++ ;
00232 }
00233
00234 return *tab[indice] ;
00235 }
00236
00237
00238
00239
00240
00241
00242 Tbl _solh_r_jaco02 (int n, int l, double echelle) {
00243
00244 const int nmax = 200 ;
00245 static Tbl* tab[nmax] ;
00246 static int nb_dejafait = 0 ;
00247 static int l_dejafait[nmax] ;
00248 static int nr_dejafait[nmax] ;
00249 static double vieux_echelle = 0;
00250
00251
00252 if (vieux_echelle != echelle) {
00253 for (int i=0 ; i<nb_dejafait ; i++) {
00254 l_dejafait[i] = -1 ;
00255 nr_dejafait[i] = -1 ;
00256 delete tab[i] ;
00257 }
00258 nb_dejafait = 0 ;
00259 vieux_echelle = echelle ;
00260 }
00261
00262 int indice = -1 ;
00263
00264
00265 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00266 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00267 indice = conte ;
00268
00269
00270 if (indice == -1) {
00271 if (nb_dejafait >= nmax) {
00272 cout << "_solh_r_jaco02 : trop de Tbl" << endl ;
00273 abort() ;
00274 exit (-1) ;
00275 }
00276
00277
00278 l_dejafait[nb_dejafait] = l ;
00279 nr_dejafait[nb_dejafait] = n ;
00280
00281
00282
00283 tab[nb_dejafait] = new Tbl(2, n) ;
00284 Tbl* pres = tab[nb_dejafait] ;
00285 pres->set_etat_qcq() ;
00286 double* coloc = new double[n] ;
00287
00288 int * deg = new int[3] ;
00289 deg[0] = 1 ;
00290 deg[1] = 1 ;
00291 deg[2] = n ;
00292
00293
00294 double* zeta = pointsgausslobatto(n-1) ;
00295
00296
00297
00298 if (l==0) {
00299 pres->set(0, 0) = 1 ;
00300 for (int i=1 ; i<n ; i++)
00301 pres->set(0, i) = 0 ;
00302 }
00303 else {
00304 for (int i=0 ; i<n ; i++)
00305 coloc[i] = pow((echelle + zeta[i]), double(l)) ;
00306
00307 cfrjaco02(deg, deg, coloc, deg, coloc) ;
00308 for (int i=0 ; i<n ;i++)
00309 pres->set(0, i) = coloc[i] ;
00310 }
00311
00312
00313
00314
00315 for (int i=0 ; i<n ; i++)
00316 coloc[i] = 1/pow((echelle + zeta[i]), double(l+1)) ;
00317
00318 cfrjaco02(deg, deg, coloc, deg, coloc) ;
00319 for (int i=0 ; i<n ;i++)
00320 pres->set(1, i) = coloc[i] ;
00321
00322
00323 delete [] coloc ;
00324 delete [] deg ;
00325 indice = nb_dejafait ;
00326 nb_dejafait ++ ;
00327 }
00328
00329 return *tab[indice] ;
00330 }
00331
00332
00333
00334
00335
00336
00337
00338 Tbl _solh_r_chebp (int n, int l, double) {
00339
00340 const int nmax = 200 ;
00341 static Tbl* tab[nmax] ;
00342 static int nb_dejafait = 0 ;
00343 static int l_dejafait[nmax] ;
00344 static int nr_dejafait[nmax] ;
00345
00346 int indice = -1 ;
00347
00348
00349 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00350 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00351 indice = conte ;
00352
00353
00354 if (indice == -1) {
00355 if (nb_dejafait >= nmax) {
00356 cout << "_solh_r_chebp : trop de Tbl" << endl ;
00357 abort() ;
00358 exit (-1) ;
00359 }
00360
00361
00362 l_dejafait[nb_dejafait] = l ;
00363 nr_dejafait[nb_dejafait] = n ;
00364
00365 assert (div(l, 2).rem ==0) ;
00366
00367
00368
00369 tab[nb_dejafait] = new Tbl(n) ;
00370 Tbl* pres = tab[nb_dejafait] ;
00371 pres->set_etat_qcq() ;
00372 double* coloc = new double[n] ;
00373
00374 int * deg = new int[3] ;
00375 deg[0] = 1 ;
00376 deg[1] = 1 ;
00377 deg[2] = n ;
00378
00379 if (l==0) {
00380 pres->set(0) = 1 ;
00381 for (int i=1 ; i<n ; i++)
00382 pres->set(i) = 0 ;
00383 }
00384 else {
00385 for (int i=0 ; i<n ; i++)
00386 coloc[i] = pow(sin(M_PI*i/2/(n-1)), double(l)) ;
00387
00388 cfrchebp(deg, deg, coloc, deg, coloc) ;
00389 for (int i=0 ; i<n ;i++)
00390 pres->set(i) = coloc[i] ;
00391 }
00392
00393 delete [] coloc ;
00394 delete [] deg ;
00395 indice = nb_dejafait ;
00396 nb_dejafait ++ ;
00397 }
00398
00399 return *tab[indice] ;
00400 }
00401
00402
00403
00404
00405
00406
00407 Tbl _solh_r_chebi (int n, int l, double) {
00408
00409 const int nmax = 200 ;
00410 static Tbl* tab[nmax] ;
00411 static int nb_dejafait = 0 ;
00412 static int l_dejafait[nmax] ;
00413 static int nr_dejafait[nmax] ;
00414
00415 int indice = -1 ;
00416
00417
00418 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00419 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00420 indice = conte ;
00421
00422
00423 if (indice == -1) {
00424 if (nb_dejafait >= nmax) {
00425 cout << "_solh_r_chebi : trop de Tbl" << endl ;
00426 abort() ;
00427 exit (-1) ;
00428 }
00429
00430
00431 l_dejafait[nb_dejafait] = l ;
00432 nr_dejafait[nb_dejafait] = n ;
00433
00434
00435 assert (div(l, 2).rem == 1) ;
00436
00437
00438 tab[nb_dejafait] = new Tbl(n) ;
00439 Tbl* pres = tab[nb_dejafait] ;
00440 pres->set_etat_qcq() ;
00441 double* coloc = new double[n] ;
00442
00443 int * deg = new int[3] ;
00444 deg[0] = 1 ;
00445 deg[1] = 1 ;
00446 deg[2] = n ;
00447
00448 if (l==1) {
00449 pres->set(0) = 1 ;
00450 for (int i=1 ; i<n ; i++)
00451 pres->set(i) = 0 ;
00452 }
00453 else {
00454 for (int i=0 ; i<n ; i++)
00455 coloc[i] = pow(sin(M_PI*i/2/(n-1)), double(l)) ;
00456
00457 cfrchebi(deg, deg, coloc, deg, coloc) ;
00458 for (int i=0 ; i<n ;i++)
00459 pres->set(i) = coloc[i] ;
00460 }
00461
00462 delete [] coloc ;
00463 delete [] deg ;
00464 indice = nb_dejafait ;
00465 nb_dejafait ++ ;
00466 }
00467
00468 return *tab[indice] ;
00469 }
00470
00471
00472
00473
00474
00475
00476
00477 Tbl _solh_r_chebu (int n, int l, double) {
00478
00479 const int nmax = 200 ;
00480 static Tbl* tab[nmax] ;
00481 static int nb_dejafait = 0 ;
00482 static int l_dejafait[nmax] ;
00483 static int nr_dejafait[nmax] ;
00484
00485 int indice = -1 ;
00486
00487
00488 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00489 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00490 indice = conte ;
00491
00492
00493 if (indice == -1) {
00494 if (nb_dejafait >= nmax) {
00495 cout << "_solh_r_chebu : trop de Tbl" << endl ;
00496 abort() ;
00497 exit (-1) ;
00498 }
00499
00500
00501 l_dejafait[nb_dejafait] = l ;
00502 nr_dejafait[nb_dejafait] = n ;
00503
00504
00505
00506 tab[nb_dejafait] = new Tbl(n) ;
00507 Tbl* pres = tab[nb_dejafait] ;
00508 pres->set_etat_qcq() ;
00509 double* coloc = new double[n] ;
00510
00511 int * deg = new int[3] ;
00512 deg[0] = 1 ;
00513 deg[1] = 1 ;
00514 deg[2] = n ;
00515
00516 for (int i=0 ; i<n ; i++)
00517 coloc[i] = pow(-1-cos(M_PI*i/(n-1)), double(l+1)) ;
00518
00519 cfrcheb(deg, deg, coloc, deg, coloc) ;
00520 for (int i=0 ; i<n ;i++)
00521 pres->set(i) = coloc[i] ;
00522
00523 delete [] coloc ;
00524 delete [] deg ;
00525 indice = nb_dejafait ;
00526 nb_dejafait ++ ;
00527 }
00528
00529 return *tab[indice] ;
00530 }
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540 Tbl solh(int n, int l, double echelle, int base_r) {
00541
00542
00543 static Tbl (*solh[MAX_BASE])(int, int, double) ;
00544 static int nap = 0 ;
00545
00546
00547 if (nap==0) {
00548 nap = 1 ;
00549 for (int i=0 ; i<MAX_BASE ; i++) {
00550 solh[i] = _solh_pas_prevu ;
00551 }
00552
00553 solh[R_CHEB >> TRA_R] = _solh_r_cheb ;
00554 solh[R_CHEBU >> TRA_R] = _solh_r_chebu ;
00555 solh[R_CHEBP >> TRA_R] = _solh_r_chebp ;
00556 solh[R_CHEBI >> TRA_R] = _solh_r_chebi ;
00557 solh[R_JACO02 >> TRA_R] = _solh_r_jaco02 ;
00558 }
00559
00560 return solh[base_r](n, l, echelle) ;
00561 }