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 cl_ptens_rr_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_pois_vect_r/cl_ptens_rr.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
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 Matrice _cl_ptens_rr_pas_prevu (const Matrice&, int, double, int) ;
00063 Matrice _cl_ptens_rr_cheb (const Matrice&, int, double, int) ;
00064 Matrice _cl_ptens_rr_chebi (const Matrice&, int, double, int) ;
00065 Matrice _cl_ptens_rr_chebu (const Matrice&, int, double, int) ;
00066 Matrice _cl_ptens_rr_chebp (const Matrice&, int, double, int) ;
00067
00068
00069 Matrice _cl_ptens_rr_pas_prevu (const Matrice &source, int l, double echelle, int puis) {
00070 cout << "Combinaison lineaire pas prevu..." << endl ;
00071 cout << "Source : " << source << endl ;
00072 cout << "l : " << l << endl ;
00073 cout << "dzpuis : " << puis << endl ;
00074 cout << "Echelle : " << echelle << endl ;
00075 abort() ;
00076 exit(-1) ;
00077 return source;
00078 }
00079
00080
00081
00082
00083
00084
00085 Matrice _cl_ptens_rr_cheb (const Matrice &source, int l, double echelle, int) {
00086 int n = source.get_dim(0) ;assert (n == source.get_dim(1)) ;
00087
00088
00089 const int nmax = 100 ;
00090 static Matrice* tab[nmax] ;
00091 static int nb_dejafait = 0 ;
00092 static int l_dejafait[nmax] ;
00093 static int nr_dejafait[nmax] ;
00094 static double vieux_echelle = 0 ;
00095
00096
00097 if (vieux_echelle != echelle) {
00098 for (int i=0 ; i<nb_dejafait ; i++) {
00099 l_dejafait[i] = -1 ;
00100 nr_dejafait[i] = -1 ;
00101 delete tab[i] ;
00102 }
00103 nb_dejafait = 0 ;
00104 vieux_echelle = echelle ;
00105 }
00106
00107 int indice = -1 ;
00108
00109
00110 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00111 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00112 indice = conte ;
00113
00114
00115 if (indice == -1) {
00116 if (nb_dejafait >= nmax) {
00117 cout << "_cl_ptens_rr_cheb : trop de matrices" << endl ;
00118 abort() ;
00119 exit (-1) ;
00120 }
00121
00122 l_dejafait[nb_dejafait] = l ;
00123 nr_dejafait[nb_dejafait] = n ;
00124
00125 Matrice barre(source) ;
00126 int dirac = 1 ;
00127 for (int i=0 ; i<n-2 ; i++) {
00128 for (int j=i ; j<(n>(i+7)? i+7 : n) ; j++)
00129 barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j))
00130 /(i+1) ;
00131 if (i==0) dirac = 0 ;
00132 }
00133
00134 Matrice res(barre) ;
00135 for (int i=0 ; i<n-4 ; i++)
00136 for (int j=i ; j<(n>(i+5)? i+5 : n) ; j++)
00137 res.set(i, j) = barre(i, j)-barre(i+2, j) ;
00138 tab[nb_dejafait] = new Matrice(res) ;
00139 nb_dejafait ++ ;
00140 return res ;
00141 }
00142
00143
00144 else
00145 return *tab[indice] ;
00146 }
00147
00148
00149
00150
00151
00152
00153 Matrice _cl_ptens_rr_chebp (const Matrice &source, int l, double, int) {
00154
00155 int n = source.get_dim(0) ;
00156 assert (n == source.get_dim(1)) ;
00157
00158 const int nmax = 100 ;
00159 static Matrice* tab[nmax] ;
00160 static int nb_dejafait = 0 ;
00161 static int l_dejafait[nmax] ;
00162 static int nr_dejafait[nmax] ;
00163
00164 int indice = -1 ;
00165
00166
00167 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00168 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00169 indice = conte ;
00170
00171
00172 if (indice == -1) {
00173 if (nb_dejafait >= nmax) {
00174 cout << "_cl_ptens_rr_chebp : trop de matrices" << endl ;
00175 abort() ;
00176 exit (-1) ;
00177 }
00178
00179 l_dejafait[nb_dejafait] = l ;
00180 nr_dejafait[nb_dejafait] = n ;
00181
00182 Matrice barre(source) ;
00183
00184 int dirac = 1 ;
00185 for (int i=0 ; i<n-2 ; i++) {
00186 for (int j=0 ; j<n ; j++)
00187 barre.set(i, j) = (1+dirac)*source(i, j)-source(i+2, j) ;
00188 if (i==0) dirac = 0 ;
00189 }
00190
00191 Matrice tilde(barre) ;
00192 for (int i=0 ; i<n-4 ; i++)
00193 for (int j=0 ; j<n ; j++)
00194 tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;
00195
00196 Matrice res(tilde) ;
00197 for (int i=0 ; i<n-4 ; i++)
00198 for (int j=0 ; j<n ; j++)
00199 res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
00200 tab[nb_dejafait] = new Matrice(res) ;
00201 nb_dejafait ++ ;
00202 return res ;
00203 }
00204
00205
00206 else
00207 return *tab[indice] ;
00208 }
00209
00210
00211
00212
00213
00214
00215 Matrice _cl_ptens_rr_chebi (const Matrice &source, int l, double, int) {
00216 int n = source.get_dim(0) ;
00217 assert (n == source.get_dim(1)) ;
00218
00219
00220 const int nmax = 100 ;
00221 static Matrice* tab[nmax] ;
00222 static int nb_dejafait = 0 ;
00223 static int l_dejafait[nmax] ;
00224 static int nr_dejafait[nmax] ;
00225
00226 int indice = -1 ;
00227
00228
00229 for (int conte=0 ; conte<nb_dejafait ; conte ++)
00230 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00231 indice = conte ;
00232
00233
00234 if (indice == -1) {
00235 if (nb_dejafait >= nmax) {
00236 cout << "_cl_ptens_rr_chebi : trop de matrices" << endl ;
00237 abort() ;
00238 exit (-1) ;
00239 }
00240
00241 l_dejafait[nb_dejafait] = l ;
00242 nr_dejafait[nb_dejafait] = n ;
00243
00244 Matrice barre(source) ;
00245
00246 for (int i=0 ; i<n-2 ; i++)
00247 for (int j=0 ; j<n ; j++)
00248 barre.set(i, j) = source(i, j)-source(i+2, j) ;
00249
00250 Matrice tilde(barre) ;
00251 for (int i=0 ; i<n-4 ; i++)
00252 for (int j=0 ; j<n ; j++)
00253 tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;
00254
00255 Matrice res(tilde) ;
00256 for (int i=0 ; i<n-4 ; i++)
00257 for (int j=0 ; j<n ; j++)
00258 res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
00259 tab[nb_dejafait] = new Matrice(res) ;
00260 nb_dejafait ++ ;
00261 return res ;
00262 }
00263
00264
00265 else
00266 return *tab[indice] ;
00267 }
00268
00269
00270
00271
00272 Matrice _cl_ptens_rr_chebu (const Matrice &source, int l, double, int puis) {
00273 int n = source.get_dim(0) ;
00274 assert (n == source.get_dim(1)) ;
00275 if (puis != 4) {
00276 cout << "_ope_ptens_rr_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 << "_cl_ptens_rr_chebu_quatre : 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 barre(source) ;
00307
00308 int dirac = 1 ;
00309 for (int i=0 ; i<n-2 ; i++) {
00310 for (int j=0 ; j<n ; j++)
00311 barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
00312 if (i==0) dirac = 0 ;
00313 }
00314
00315 Matrice tilde(barre) ;
00316 for (int i=0 ; i<n-4 ; i++)
00317 for (int j=0 ; j<n ; j++)
00318 tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
00319
00320 Matrice prime(tilde) ;
00321 for (int i=0 ; i<n-4 ; i++)
00322 for (int j=0 ; j<n ; j++)
00323 prime.set(i, j) = (tilde(i, j)-tilde(i+1, j)) ;
00324
00325 Matrice res(prime) ;
00326 for (int i=0 ; i<n-4 ; i++)
00327 for (int j=0 ; j<n ; j++)
00328 res.set(i, j) = (prime(i, j)-prime(i+2, j)) ;
00329 tab[nb_dejafait] = new Matrice(res) ;
00330 nb_dejafait ++ ;
00331 return res ;
00332 }
00333
00334
00335 else
00336 return *tab[indice] ;
00337 }
00338
00339
00340
00341
00342
00343
00344 Matrice cl_ptens_rr(const Matrice &source, int l, double echelle,
00345 int puis, int base_r) {
00346
00347
00348 static Matrice (*combinaison[MAX_BASE])(const Matrice &, int, double, int) ;
00349 static int nap = 0 ;
00350
00351
00352 if (nap==0) {
00353 nap = 1 ;
00354 for (int i=0 ; i<MAX_BASE ; i++) {
00355 combinaison[i] = _cl_ptens_rr_pas_prevu ;
00356 }
00357
00358 combinaison[R_CHEB >> TRA_R] = _cl_ptens_rr_cheb ;
00359 combinaison[R_CHEBU >> TRA_R] = _cl_ptens_rr_chebu ;
00360 combinaison[R_CHEBP >> TRA_R] = _cl_ptens_rr_chebp ;
00361 combinaison[R_CHEBI >> TRA_R] = _cl_ptens_rr_chebi ;
00362 }
00363
00364 Matrice res(combinaison[base_r](source, l, echelle, puis)) ;
00365 return res ;
00366 }
00367