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