00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 char prepa_poisson_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/prepa_poisson.C,v 1.7 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
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 #include <stdio.h>
00112 #include <stdlib.h>
00113 #include <math.h>
00114
00115 #include "matrice.h"
00116 #include "type_parite.h"
00117 #include "proto.h"
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 Matrice _prepa_nondege_pas_prevu(const Matrice &lap, int l, double echelle, int puis) {
00142 cout << "Construction non degeneree pas prevue..." << endl ;
00143 cout << "l : " << l << endl ;
00144 cout << "lap : " << lap << endl ;
00145 cout << "echelle : " << echelle << endl ;
00146 cout << " puis : " << puis << endl ;
00147 abort() ;
00148 exit(-1) ;
00149 Matrice res(1, 1) ;
00150 return res;
00151 }
00152
00153
00154
00155
00156
00157
00158
00159 Matrice _prepa_nondege_r_cheb (const Matrice &lap, int l, double echelle, int) {
00160
00161
00162 int n = lap.get_dim(0) ;
00163
00164 const int nmax = 200 ;
00165 static Matrice* tab[nmax] ;
00166 static int nb_dejafait = 0 ;
00167 static int l_dejafait[nmax] ;
00168 static int nr_dejafait[nmax] ;
00169 static double vieux_echelle = 0;
00170
00171
00172 if (vieux_echelle != echelle) {
00173 for (int i=0 ; i<nb_dejafait ; i++) {
00174 l_dejafait[i] = -1 ;
00175 nr_dejafait[i] = -1 ;
00176 delete tab[i] ;
00177 }
00178 vieux_echelle = echelle ;
00179 nb_dejafait = 0 ;
00180 }
00181
00182 int indice = -1 ;
00183
00184
00185 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00186 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00187 indice = conte ;
00188
00189
00190 if (indice == -1) {
00191 if (nb_dejafait >= nmax) {
00192 cout << "_prepa_nondege_r_cheb : trop de matrices" << endl ;
00193 abort() ;
00194 exit (-1) ;
00195 }
00196
00197
00198 l_dejafait[nb_dejafait] = l ;
00199 nr_dejafait[nb_dejafait] = n ;
00200
00201
00202
00203
00204 Matrice res(n-2, n-2) ;
00205 res.set_etat_qcq() ;
00206 for (int i=0 ; i<n-2 ; i++)
00207 for (int j=0 ; j<n-2 ; j++)
00208 res.set(i, j) = lap(i, j+2) ;
00209
00210 res.set_band(2, 2) ;
00211 res.set_lu() ;
00212 tab[nb_dejafait] = new Matrice(res) ;
00213 nb_dejafait ++ ;
00214 return res ;
00215 }
00216
00217
00218 else
00219 return *tab[indice] ;
00220 }
00221
00222
00223
00224
00225
00226
00227 Matrice _prepa_nondege_r_jaco02 (const Matrice &lap, int l, double echelle, int) {
00228
00229
00230 int n = lap.get_dim(0) ;
00231
00232 const int nmax = 200 ;
00233 static Matrice* tab[nmax] ;
00234 static int nb_dejafait = 0 ;
00235 static int l_dejafait[nmax] ;
00236 static int nr_dejafait[nmax] ;
00237 static double vieux_echelle = 0;
00238
00239
00240 if (vieux_echelle != echelle) {
00241 for (int i=0 ; i<nb_dejafait ; i++) {
00242 l_dejafait[i] = -1 ;
00243 nr_dejafait[i] = -1 ;
00244 delete tab[i] ;
00245 }
00246 vieux_echelle = echelle ;
00247 nb_dejafait = 0 ;
00248 }
00249
00250 int indice = -1 ;
00251
00252
00253 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00254 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00255 indice = conte ;
00256
00257
00258 if (indice == -1) {
00259 if (nb_dejafait >= nmax) {
00260 cout << "_prepa_nondege_r_jaco02 : trop de matrices" << endl ;
00261 abort() ;
00262 exit (-1) ;
00263 }
00264
00265
00266 l_dejafait[nb_dejafait] = l ;
00267 nr_dejafait[nb_dejafait] = n ;
00268
00269
00270
00271
00272 Matrice res(n-2, n-2) ;
00273 res.set_etat_qcq() ;
00274 for (int i=0 ; i<n-2 ; i++)
00275 for (int j=0 ; j<n-2 ; j++)
00276 res.set(i, j) = lap(i, j+2) ;
00277
00278 res.set_band(2, 2) ;
00279 res.set_lu() ;
00280 tab[nb_dejafait] = new Matrice(res) ;
00281 nb_dejafait ++ ;
00282 return res ;
00283 }
00284
00285
00286 else
00287 return *tab[indice] ;
00288 }
00289
00290
00291
00292
00293
00294 Matrice _prepa_nondege_r_chebp (const Matrice &lap, int l, double, int) {
00295
00296 int n = lap.get_dim(0) ;
00297
00298
00299 const int nmax = 200 ;
00300 static Matrice* tab[nmax] ;
00301 static int nb_dejafait = 0 ;
00302 static int l_dejafait[nmax] ;
00303 static int nr_dejafait[nmax] ;
00304
00305 int indice = -1 ;
00306
00307
00308 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00309 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00310 indice = conte ;
00311
00312
00313 if (indice == -1) {
00314 if (nb_dejafait >= nmax) {
00315 cout << "_prepa_nondege_r_chebp : trop de matrices" << endl ;
00316 abort() ;
00317 exit (-1) ;
00318 }
00319
00320
00321 l_dejafait[nb_dejafait] = l ;
00322 nr_dejafait[nb_dejafait] = n ;
00323
00324 assert (div(l, 2).rem == 0) ;
00325
00326
00327 if (l==0) {
00328 Matrice res(n-1, n-1) ;
00329 res.set_etat_qcq() ;
00330 for (int i=0 ; i<n-1 ; i++)
00331 for (int j=0 ; j<n-1 ; j++)
00332 res.set(i, j) = lap(i, j+1) ;
00333 res.set_band(3, 0) ;
00334 res.set_lu() ;
00335 tab[nb_dejafait] = new Matrice(res) ;
00336 nb_dejafait ++ ;
00337 return res ;
00338 }
00339 else {
00340 Matrice res(n-2, n-2) ;
00341 res.set_etat_qcq() ;
00342 for (int i=0 ;i<n-2 ; i++)
00343 for (int j=0 ; j<n-2 ; j++)
00344 res.set(i, j) = lap(i, j+2) ;
00345
00346 res.set_band(2, 1) ;
00347 res.set_lu() ;
00348 tab[nb_dejafait] = new Matrice(res) ;
00349 nb_dejafait ++ ;
00350 return res ;
00351 }
00352 }
00353
00354 else
00355 return *tab[indice] ;
00356 }
00357
00358
00359
00360
00361
00362
00363
00364
00365 Matrice _prepa_nondege_r_chebi (const Matrice &lap, int l, double, int) {
00366
00367 int n = lap.get_dim(0) ;
00368
00369 const int nmax = 200 ;
00370 static Matrice* tab[nmax] ;
00371 static int nb_dejafait = 0 ;
00372 static int l_dejafait[nmax] ;
00373 static int nr_dejafait[nmax] ;
00374
00375 int indice = -1 ;
00376
00377
00378 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00379 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00380 indice = conte ;
00381
00382
00383 if (indice == -1) {
00384 if (nb_dejafait >= nmax) {
00385 cout << "_prepa_nondege_r_chebi : trop de matrices" << endl ;
00386 abort() ;
00387 exit (-1) ;
00388 }
00389
00390
00391 l_dejafait[nb_dejafait] = l ;
00392 nr_dejafait[nb_dejafait] = n ;
00393
00394
00395 assert (div(l, 2).rem == 1) ;
00396
00397
00398 if (l==1) {
00399 Matrice res(n-1, n-1) ;
00400 res.set_etat_qcq() ;
00401 for (int i=0 ; i<n-1 ; i++)
00402 for (int j=0 ; j<n-1 ; j++)
00403 res.set(i, j) = lap(i, j+1) ;
00404 res.set_band(3, 0) ;
00405 res.set_lu() ;
00406 tab[nb_dejafait] = new Matrice(res) ;
00407 nb_dejafait ++ ;
00408 return res ;
00409 }
00410 else {
00411 Matrice res(n-2, n-2) ;
00412 res.set_etat_qcq() ;
00413 for (int i=0 ;i<n-2 ; i++)
00414 for (int j=0 ; j<n-2 ; j++)
00415 res.set(i, j) = lap(i, j+2) ;
00416
00417 res.set_band(2, 1) ;
00418 res.set_lu() ;
00419 tab[nb_dejafait] = new Matrice(res) ;
00420 nb_dejafait ++ ;
00421 return res ;
00422 }
00423 }
00424
00425 else
00426 return *tab[indice] ;
00427 }
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437 Matrice _prepa_nondege_r_chebu (const Matrice &lap, int l, double, int puis) {
00438
00439 switch (puis) {
00440 case 5 :
00441 return _prepa_nondege_r_chebu_cinq (lap, l) ;
00442 case 4 :
00443 return _prepa_nondege_r_chebu_quatre (lap, l) ;
00444 case 3 :
00445 return _prepa_nondege_r_chebu_trois (lap, l) ;
00446 case 2 :
00447 return _prepa_nondege_r_chebu_deux (lap, l) ;
00448 default :
00449 abort() ;
00450 exit(-1) ;
00451 return Matrice(0, 0) ;
00452 }
00453 }
00454
00455
00456 Matrice _prepa_nondege_r_chebu_quatre (const Matrice &lap, int l) {
00457
00458 int n = lap.get_dim(0) ;
00459
00460 const int nmax = 200;
00461 static Matrice* tab[nmax] ;
00462 static int nb_dejafait = 0 ;
00463 static int l_dejafait[nmax] ;
00464 static int nr_dejafait[nmax] ;
00465
00466 int indice = -1 ;
00467
00468
00469 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00470 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00471 indice = conte ;
00472
00473
00474 if (indice == -1) {
00475 if (nb_dejafait >= nmax) {
00476 cout << "_prepa_nondege_r_chebu : trop de matrices" << endl ;
00477 abort() ;
00478 exit (-1) ;
00479 }
00480
00481
00482 l_dejafait[nb_dejafait] = l ;
00483 nr_dejafait[nb_dejafait] = n ;
00484
00485
00486
00487 if (l==0) {
00488 Matrice res(n-2, n-2) ;
00489 res.set_etat_qcq() ;
00490 for (int i=0 ; i<n-2 ; i++)
00491 for (int j=0 ; j<n-2 ; j++)
00492 res.set(i, j) = lap(i, j+2) ;
00493 res.set_band(3, 0) ;
00494 res.set_lu() ;
00495 tab[nb_dejafait] = new Matrice(res) ;
00496 nb_dejafait ++ ;
00497 return res ;
00498 }
00499 else {
00500 Matrice res(n-3, n-3) ;
00501 res.set_etat_qcq() ;
00502 for (int i=0 ;i<n-3 ; i++)
00503 for (int j=0 ; j<n-3 ; j++)
00504 res.set(i, j) = lap(i, j+3) ;
00505
00506 res.set_band(2, 1) ;
00507 res.set_lu() ;
00508 tab[nb_dejafait] = new Matrice(res) ;
00509 nb_dejafait ++ ;
00510 return res ;
00511 }
00512 }
00513
00514 else
00515 return *tab[indice] ;
00516 }
00517
00518 Matrice _prepa_nondege_r_chebu_trois (const Matrice &lap, int l) {
00519
00520 int n = lap.get_dim(0) ;
00521
00522 const int nmax = 200;
00523 static Matrice* tab[nmax] ;
00524 static int nb_dejafait = 0 ;
00525 static int l_dejafait[nmax] ;
00526 static int nr_dejafait[nmax] ;
00527
00528 int indice = -1 ;
00529
00530
00531 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00532 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00533 indice = conte ;
00534
00535
00536 if (indice == -1) {
00537 if (nb_dejafait >= nmax) {
00538 cout << "_prepa_nondege_r_chebu_trois : trop de matrices" << endl ;
00539 abort() ;
00540 exit (-1) ;
00541 }
00542
00543 l_dejafait[nb_dejafait] = l ;
00544 nr_dejafait[nb_dejafait] = n ;
00545
00546 Matrice res(n-2, n-2) ;
00547 res.set_etat_qcq() ;
00548 for (int i=0 ; i<n-2 ; i++)
00549 for (int j=0 ; j<n-2 ; j++)
00550 res.set(i, j) = lap(i, j+2) ;
00551 res.set_band(2, 1) ;
00552 res.set_lu() ;
00553 tab[nb_dejafait] = new Matrice(res) ;
00554 nb_dejafait ++ ;
00555 return res ;
00556 }
00557
00558 else
00559 return *tab[indice] ;
00560 }
00561
00562
00563 Matrice _prepa_nondege_r_chebu_deux (const Matrice &lap, int l) {
00564
00565 int n = lap.get_dim(0) ;
00566
00567 const int nmax = 200;
00568 static Matrice* tab[nmax] ;
00569 static int nb_dejafait = 0 ;
00570 static int l_dejafait[nmax] ;
00571 static int nr_dejafait[nmax] ;
00572
00573 int indice = -1 ;
00574
00575
00576 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00577 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00578 indice = conte ;
00579
00580
00581 if (indice == -1) {
00582 if (nb_dejafait >= nmax) {
00583 cout << "_prepa_nondege_r_chebu : trop de matrices" << endl ;
00584 abort() ;
00585 exit (-1) ;
00586 }
00587
00588
00589 l_dejafait[nb_dejafait] = l ;
00590 nr_dejafait[nb_dejafait] = n ;
00591
00592
00593
00594 if (l==0) {
00595 Matrice res(n-2, n-2) ;
00596 res.set_etat_qcq() ;
00597 for (int i=0 ;i<n-2 ; i++)
00598 for (int j=0 ; j<n-2 ; j++)
00599 res.set(i, j) = lap(i, j+2) ;
00600 res.set_band(3, 2) ;
00601 res.set_lu() ;
00602 tab[nb_dejafait] = new Matrice(res) ;
00603 nb_dejafait ++ ;
00604 return res ;
00605 }
00606 else {
00607 Matrice res(n-1, n-1) ;
00608 res.set_etat_qcq() ;
00609 for (int i=0 ;i<n-1 ; i++)
00610 for (int j=0 ; j<n-1 ; j++)
00611 res.set(i, j) = lap(i, j+1) ;
00612 res.set_band(4, 1) ;
00613 res.set_lu() ;
00614 tab[nb_dejafait] = new Matrice(res) ;
00615 nb_dejafait ++ ;
00616 return res ;
00617 }
00618 }
00619
00620 else
00621 return *tab[indice] ;
00622 }
00623
00624
00625 Matrice _prepa_nondege_r_chebu_cinq (const Matrice &lap, int l) {
00626
00627 int n = lap.get_dim(0) ;
00628
00629 const int nmax = 200;
00630 static Matrice* tab[nmax] ;
00631 static int nb_dejafait = 0 ;
00632 static int l_dejafait[nmax] ;
00633 static int nr_dejafait[nmax] ;
00634
00635 int indice = -1 ;
00636
00637
00638 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00639 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00640 indice = conte ;
00641
00642
00643 if (indice == -1) {
00644 if (nb_dejafait >= nmax) {
00645 cout << "_prepa_nondege_r_chebu : trop de matrices" << endl ;
00646 abort() ;
00647 exit (-1) ;
00648 }
00649
00650
00651 l_dejafait[nb_dejafait] = l ;
00652 nr_dejafait[nb_dejafait] = n ;
00653
00654
00655
00656 if (l<2) {
00657 tab[nb_dejafait] = new Matrice(lap) ;
00658 tab[nb_dejafait]->set_band(5,0) ;
00659 tab[nb_dejafait]->set_lu() ;
00660 nb_dejafait++ ;
00661 return *tab[nb_dejafait-1] ;
00662 }
00663 else {
00664 Matrice res(n-1, n-1) ;
00665 res.set_etat_qcq() ;
00666 for (int i=0 ;i<n-1 ; i++)
00667 for (int j=0 ; j<n-1 ; j++)
00668 res.set(i, j) = lap(i, j+1) ;
00669 res.set_band(4, 1) ;
00670 res.set_lu() ;
00671 tab[nb_dejafait] = new Matrice(res) ;
00672 nb_dejafait ++ ;
00673 return res ;
00674 }
00675
00676 }
00677
00678 else
00679 return *tab[indice] ;
00680 }
00681
00682
00683
00684
00685
00686
00687 Matrice prepa_nondege(const Matrice &lap, int l, double echelle, int puis, int base_r)
00688 {
00689
00690
00691 static Matrice (*prepa_nondege[MAX_BASE])(const Matrice&, int, double, int) ;
00692 static int nap = 0 ;
00693
00694
00695 if (nap==0) {
00696 nap = 1 ;
00697 for (int i=0 ; i<MAX_BASE ; i++) {
00698 prepa_nondege[i] = _prepa_nondege_pas_prevu ;
00699 }
00700
00701 prepa_nondege[R_CHEB >> TRA_R] = _prepa_nondege_r_cheb ;
00702 prepa_nondege[R_CHEBU >> TRA_R] = _prepa_nondege_r_chebu ;
00703 prepa_nondege[R_CHEBP >> TRA_R] = _prepa_nondege_r_chebp ;
00704 prepa_nondege[R_CHEBI >> TRA_R] = _prepa_nondege_r_chebi ;
00705 prepa_nondege[R_JACO02 >> TRA_R] = _prepa_nondege_r_jaco02 ;
00706 }
00707
00708 Matrice res(prepa_nondege[base_r](lap, l, echelle, puis)) ;
00709 return res ;
00710 }
00711