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 ope_pvect_r_mat_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_pois_vect_r/ope_pvect_r_mat.C,v 1.1 2004/05/10 15:28:22 j_novak Exp $" ;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044
00045 #include "matrice.h"
00046 #include "type_parite.h"
00047 #include "proto.h"
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 Matrice _ope_pvect_r_mat_pas_prevu(int, int, double, int) ;
00070 Matrice _ope_pvect_r_mat_r_chebp(int, int, double, int) ;
00071 Matrice _ope_pvect_r_mat_r_chebi(int, int, double, int) ;
00072 Matrice _ope_pvect_r_mat_r_chebu(int, int, double, int) ;
00073 Matrice _ope_pvect_r_mat_r_cheb(int, int, double, int) ;
00074
00075
00076
00077
00078
00079 Matrice _ope_pvect_r_mat_pas_prevu(int n, int l, double echelle, int puis) {
00080 cout << "laplacien vect_r pas prevu..." << endl ;
00081 cout << "n : " << n << endl ;
00082 cout << "l : " << l << endl ;
00083 cout << "puissance : " << puis << endl ;
00084 cout << "echelle : " << echelle << endl ;
00085 abort() ;
00086 exit(-1) ;
00087 Matrice res(1, 1) ;
00088 return res;
00089 }
00090
00091
00092
00093
00094
00095
00096
00097 Matrice _ope_pvect_r_mat_r_chebp (int n, int l, double, int) {
00098
00099 const int nmax = 100 ;
00100 static Matrice* tab[nmax] ;
00101 static int nb_dejafait = 0 ;
00102 static int l_dejafait[nmax] ;
00103 static int nr_dejafait[nmax] ;
00104
00105 int indice = -1 ;
00106
00107
00108 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00109 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00110 indice = conte ;
00111
00112
00113 if (indice == -1) {
00114 if (nb_dejafait >= nmax) {
00115 cout << "_ope_pvect_r_mat_r_chebp : trop de matrices" << endl ;
00116 abort() ;
00117 exit (-1) ;
00118 }
00119
00120
00121 l_dejafait[nb_dejafait] = l ;
00122 nr_dejafait[nb_dejafait] = n ;
00123
00124 Matrice dd(n, n) ;
00125 dd.set_etat_qcq() ;
00126 Matrice xd(n, n) ;
00127 xd.set_etat_qcq() ;
00128 Matrice xx(n, n) ;
00129 xx.set_etat_qcq() ;
00130
00131 double* vect = new double[n] ;
00132
00133 for (int i=0 ; i<n ; i++) {
00134 for (int j=0 ; j<n ; j++)
00135 vect[j] = 0 ;
00136 vect[i] = 1 ;
00137 d2sdx2_1d (n, &vect, R_CHEBP) ;
00138
00139 for (int j=0 ; j<n ; j++)
00140 dd.set(j, i) = vect[j] ;
00141 }
00142
00143 for (int i=0 ; i<n ; i++) {
00144 for (int j=0 ; j<n ; j++)
00145 vect[j] = 0 ;
00146 vect[i] = 1 ;
00147 sxdsdx_1d (n, &vect, R_CHEBP) ;
00148 for (int j=0 ; j<n ; j++)
00149 xd.set(j, i) = vect[j] ;
00150
00151 }
00152
00153 for (int i=0 ; i<n ; i++) {
00154 for (int j=0 ; j<n ; j++)
00155 vect[j] = 0 ;
00156 vect[i] = 1 ;
00157 sx2_1d (n, &vect, R_CHEBP) ;
00158 for (int j=0 ; j<n ; j++)
00159 xx.set(j, i) = vect[j] ;
00160 }
00161
00162 delete [] vect ;
00163
00164 Matrice res(n, n) ;
00165 if (l != 0)
00166 res = dd+4*xd+(2-l*(l+1))*xx ;
00167 else
00168 res = dd + 2*xd - 2*xx ;
00169 tab[nb_dejafait] = new Matrice(res) ;
00170 nb_dejafait ++ ;
00171 return res ;
00172 }
00173
00174
00175 else
00176 return *tab[indice] ;
00177 }
00178
00179
00180
00181
00182
00183
00184
00185
00186 Matrice _ope_pvect_r_mat_r_chebi (int n, int l, double, int) {
00187
00188 const int nmax = 100 ;
00189 static Matrice* 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 << "_ope_pvect_r_mat_r_chebi : trop de matrices" << endl ;
00205 abort() ;
00206 exit (-1) ;
00207 }
00208
00209
00210 l_dejafait[nb_dejafait] = l ;
00211 nr_dejafait[nb_dejafait] = n ;
00212
00213 Matrice dd(n, n) ;
00214 dd.set_etat_qcq() ;
00215 Matrice xd(n, n) ;
00216 xd.set_etat_qcq() ;
00217 Matrice xx(n, n) ;
00218 xx.set_etat_qcq() ;
00219
00220 double* vect = new double[n] ;
00221
00222 for (int i=0 ; i<n ; i++) {
00223 for (int j=0 ; j<n ; j++)
00224 vect[j] = 0 ;
00225 vect[i] = 1 ;
00226 d2sdx2_1d (n, &vect, R_CHEBI) ;
00227 for (int j=0 ; j<n ; j++)
00228 dd.set(j, i) = vect[j] ;
00229 }
00230
00231 for (int i=0 ; i<n ; i++) {
00232 for (int j=0 ; j<n ; j++)
00233 vect[j] = 0 ;
00234 vect[i] = 1 ;
00235 sxdsdx_1d (n, &vect, R_CHEBI) ;
00236 for (int j=0 ; j<n ; j++)
00237 xd.set(j, i) = vect[j] ;
00238 }
00239
00240 for (int i=0 ; i<n ; i++) {
00241 for (int j=0 ; j<n ; j++)
00242 vect[j] = 0 ;
00243 vect[i] = 1 ;
00244 sx2_1d (n, &vect, R_CHEBI) ;
00245 for (int j=0 ; j<n ; j++)
00246 xx.set(j, i) = vect[j] ;
00247 }
00248
00249 delete [] vect ;
00250
00251 Matrice res(n, n) ;
00252 if (l != 0)
00253 res = dd+4*xd+(2-l*(l+1))*xx ;
00254 else
00255 res = dd + 2*xd - 2*xx ;
00256 tab[nb_dejafait] = new Matrice(res) ;
00257 nb_dejafait ++ ;
00258 return res ;
00259 }
00260
00261
00262 else
00263 return *tab[indice] ;
00264 }
00265
00266
00267
00268
00269
00270
00271
00272
00273 Matrice _ope_pvect_r_mat_r_chebu( int n, int l, double, int puis) {
00274
00275 if (puis != 4) {
00276 cout << "_ope_pvect_r_mat_r_chebu : only the case dzpuis = 4 "
00277 << '\n' << "is implemented! \n"
00278 << "dzpuis = " << puis << endl ;
00279 abort() ;
00280 }
00281
00282 const int nmax = 200 ;
00283 static Matrice* tab[nmax] ;
00284 static int nb_dejafait = 0 ;
00285 static int l_dejafait[nmax] ;
00286 static int nr_dejafait[nmax] ;
00287
00288 int indice = -1 ;
00289
00290
00291 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00292 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00293 indice = conte ;
00294
00295
00296 if (indice == -1) {
00297 if (nb_dejafait >= nmax) {
00298 cout << "_ope_pvect_r_mat_r_chebu : trop de matrices" << endl ;
00299 abort() ;
00300 exit (-1) ;
00301 }
00302
00303 l_dejafait[nb_dejafait] = l ;
00304 nr_dejafait[nb_dejafait] = n ;
00305
00306 Matrice dd(n, n) ;
00307 dd.set_etat_qcq() ;
00308 Matrice xd(n, n) ;
00309 xd.set_etat_qcq() ;
00310 Matrice xx(n, n) ;
00311 xx.set_etat_qcq() ;
00312
00313 double* vect = new double[n] ;
00314
00315 for (int i=0 ; i<n ; i++) {
00316 for (int j=0 ; j<n ; j++)
00317 vect[j] = 0 ;
00318 vect[i] = 1 ;
00319 d2sdx2_1d (n, &vect, R_CHEBU) ;
00320 for (int j=0 ; j<n ; j++)
00321 dd.set(j, i) = vect[j] ;
00322 }
00323
00324 for (int i=0 ; i<n ; i++) {
00325 for (int j=0 ; j<n ; j++)
00326 vect[j] = 0 ;
00327 vect[i] = 1 ;
00328 dsdx_1d (n, &vect, R_CHEBU) ;
00329 sxm1_1d_cheb (n, vect) ;
00330 for (int j=0 ; j<n ; j++)
00331 xd.set(j, i) = vect[j] ;
00332 }
00333
00334 for (int i=0 ; i<n ; i++) {
00335 for (int j=0 ; j<n ; j++)
00336 vect[j] = 0 ;
00337 vect[i] = 1 ;
00338 sx2_1d (n, &vect, R_CHEBU) ;
00339 for (int j=0 ; j<n ; j++)
00340 xx.set(j, i) = vect[j] ;
00341 }
00342
00343 delete [] vect ;
00344
00345 Matrice res(n, n) ;
00346 if (l == 0)
00347 res = dd-2*xx ;
00348 else
00349 res = dd - 2*xd + (2 -l*(l+1))*xx ;
00350 tab[nb_dejafait] = new Matrice(res) ;
00351 nb_dejafait ++ ;
00352 return res ;
00353 }
00354
00355
00356 else
00357 return *tab[indice] ;
00358 }
00359
00360
00361
00362
00363
00364
00365
00366 Matrice _ope_pvect_r_mat_r_cheb (int n, int l, double echelle, int) {
00367
00368 const int nmax = 200 ;
00369 static Matrice* tab[nmax] ;
00370 static int nb_dejafait = 0 ;
00371 static int l_dejafait[nmax] ;
00372 static int nr_dejafait[nmax] ;
00373 static double vieux_echelle = 0;
00374
00375
00376 if (vieux_echelle != echelle) {
00377 for (int i=0 ; i<nb_dejafait ; i++) {
00378 l_dejafait[i] = -1 ;
00379 nr_dejafait[i] = -1 ;
00380 delete tab[i] ;
00381 }
00382
00383 nb_dejafait = 0 ;
00384 vieux_echelle = echelle ;
00385 }
00386
00387 int indice = -1 ;
00388
00389
00390 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00391 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00392 indice = conte ;
00393
00394
00395 if (indice == -1) {
00396 if (nb_dejafait >= nmax) {
00397 cout << "_ope_pvect_r_mat_r_cheb : trop de matrices" << endl ;
00398 abort() ;
00399 exit (-1) ;
00400 }
00401
00402
00403 l_dejafait[nb_dejafait] = l ;
00404 nr_dejafait[nb_dejafait] = n ;
00405
00406 Matrice dd(n, n) ;
00407 dd.set_etat_qcq() ;
00408 Matrice xd(n, n) ;
00409 xd.set_etat_qcq() ;
00410 Matrice xx(n, n) ;
00411 xx.set_etat_qcq() ;
00412
00413 double* vect = new double[n] ;
00414
00415 for (int i=0 ; i<n ; i++) {
00416 for (int j=0 ; j<n ; j++)
00417 vect[j] = 0 ;
00418 vect[i] = 1 ;
00419 d2sdx2_1d (n, &vect, R_CHEB) ;
00420 for (int j=0 ; j<n ; j++)
00421 dd.set(j, i) = vect[j]*echelle*echelle ;
00422 }
00423
00424 for (int i=0 ; i<n ; i++) {
00425 for (int j=0 ; j<n ; j++)
00426 vect[j] = 0 ;
00427 vect[i] = 1 ;
00428 d2sdx2_1d (n, &vect, R_CHEB) ;
00429 multx_1d (n, &vect, R_CHEB) ;
00430 for (int j=0 ; j<(n>i+1 ? i+1 : n) ; j++)
00431 dd.set(j, i) += 2*echelle*vect[j] ;
00432 }
00433
00434 for (int i=0 ; i<n ; i++) {
00435 for (int j=0 ; j<n ; j++)
00436 vect[j] = 0 ;
00437 vect[i] = 1 ;
00438 d2sdx2_1d (n, &vect, R_CHEB) ;
00439 multx_1d (n, &vect, R_CHEB) ;
00440 multx_1d (n, &vect, R_CHEB) ;
00441 for (int j=0 ; j<(n>i+1 ? i+1 : n) ; j++)
00442 dd.set(j, i) += vect[j] ;
00443 }
00444
00445 for (int i=0 ; i<n ; i++) {
00446 for (int j=0 ; j<n ; j++)
00447 vect[j] = 0 ;
00448 vect[i] = 1 ;
00449 sxdsdx_1d (n, &vect, R_CHEB) ;
00450 for (int j=0 ; j<n ; j++)
00451 xd.set(j, i) = vect[j]*echelle ;
00452 }
00453
00454 for (int i=0 ; i<n ; i++) {
00455 for (int j=0 ; j<n ; j++)
00456 vect[j] = 0 ;
00457 vect[i] = 1 ;
00458 sxdsdx_1d (n, &vect, R_CHEB) ;
00459 multx_1d (n, &vect, R_CHEB) ;
00460 for (int j=0 ; j<(n>i+1 ? i+1 : n) ; j++)
00461 xd.set(j, i) += vect[j] ;
00462 }
00463
00464 for (int i=0 ; i<n ; i++) {
00465 for (int j=0 ; j<n ; j++)
00466 vect[j] = 0 ;
00467 vect[i] = 1 ;
00468 sx2_1d (n, &vect, R_CHEB) ;
00469 for (int j=0 ; j<n ; j++)
00470 xx.set(j, i) = vect[j] ;
00471 }
00472
00473 delete [] vect ;
00474
00475 Matrice res(n, n) ;
00476 if (l == 0)
00477 res = dd+2*xd-2*xx ;
00478 else
00479 res = dd + 4*xd + (2 - l*(l+1))*xx ;
00480 tab[nb_dejafait] = new Matrice(res) ;
00481 nb_dejafait ++ ;
00482 return res ;
00483 }
00484
00485
00486 else
00487 return *tab[indice] ;
00488 }
00489
00490
00491
00492
00493
00494
00495 Matrice ope_pvect_r_mat(int n, int l, double echelle, int puis, int base_r)
00496 {
00497
00498
00499 static Matrice (*ope_pvect_r_mat[MAX_BASE])(int, int, double, int) ;
00500 static int nap = 0 ;
00501
00502
00503 if (nap==0) {
00504 nap = 1 ;
00505 for (int i=0 ; i<MAX_BASE ; i++) {
00506 ope_pvect_r_mat[i] = _ope_pvect_r_mat_pas_prevu ;
00507 }
00508
00509 ope_pvect_r_mat[R_CHEB >> TRA_R] = _ope_pvect_r_mat_r_cheb ;
00510 ope_pvect_r_mat[R_CHEBU >> TRA_R] = _ope_pvect_r_mat_r_chebu ;
00511 ope_pvect_r_mat[R_CHEBP >> TRA_R] = _ope_pvect_r_mat_r_chebp ;
00512 ope_pvect_r_mat[R_CHEBI >> TRA_R] = _ope_pvect_r_mat_r_chebi ;
00513 }
00514
00515 Matrice res(ope_pvect_r_mat[base_r](n, l, echelle, puis)) ;
00516 return res ;
00517 }
00518