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 char valeur_coef_C[] = "$Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_coef.C,v 1.15 2012/01/17 17:51:16 j_penner Exp $" ;
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
00112
00113
00114
00115
00116
00117
00118 #include<cmath>
00119
00120
00121 #include "mtbl.h"
00122 #include "mtbl_cf.h"
00123 #include "valeur.h"
00124 #include "proto.h"
00125
00126
00127 void pasprevu_r(const int*, const int*, double*, const int*, double*) ;
00128 void pasprevu_t(const int*, const int*, double*, const int*, double*) ;
00129 void pasprevu_p(const int* ,const int* , double* ) ;
00130
00131 void base_non_def_r(const int*, const int*, double*, const int*, double*) ;
00132 void base_non_def_t(const int*, const int*, double*, const int*, double*) ;
00133 void base_non_def_p(const int* ,const int* , double* ) ;
00134
00135 bool admissible_fft(int ) ;
00136
00137 void Valeur::coef() const {
00138
00139
00140 static void (*coef_r[MAX_BASE])(const int*, const int*, double*, const int*, double*) ;
00141 static void (*coef_t[MAX_BASE])(const int*, const int*, double*, const int*, double*) ;
00142 static void (*coef_p[MAX_BASE_2])(const int* ,const int* , double* ) ;
00143 static int premier_appel = 1 ;
00144
00145
00146 if (premier_appel) {
00147 premier_appel = 0 ;
00148
00149 for (int i=0; i<MAX_BASE; i++) {
00150 coef_r[i] = pasprevu_r ;
00151 coef_t[i] = pasprevu_t ;
00152 if(i%2 == 0){
00153 coef_p[i/2] = pasprevu_p ;
00154 }
00155 }
00156
00157 coef_r[NONDEF] = base_non_def_r ;
00158 coef_r[R_CHEB >> TRA_R] = cfrcheb ;
00159 coef_r[R_CHEBU >> TRA_R] = cfrcheb ;
00160 coef_r[R_CHEBP >> TRA_R] = cfrchebp ;
00161 coef_r[R_CHEBI >> TRA_R] = cfrchebi ;
00162 coef_r[R_CHEBPIM_P >> TRA_R] = cfrchebpimp ;
00163 coef_r[R_CHEBPIM_I >> TRA_R] = cfrchebpimi ;
00164 coef_r[R_CHEBPI_P >> TRA_R] = cfrchebpip ;
00165 coef_r[R_CHEBPI_I >> TRA_R] = cfrchebpii ;
00166 coef_r[R_JACO02 >> TRA_R] = cfrjaco02 ;
00167
00168 coef_t[NONDEF] = base_non_def_t ;
00169 coef_t[T_COS >> TRA_T] = cftcos ;
00170 coef_t[T_SIN >> TRA_T] = cftsin ;
00171 coef_t[T_COS_P >> TRA_T] = cftcosp ;
00172 coef_t[T_COS_I >> TRA_T] = cftcosi ;
00173 coef_t[T_SIN_P >> TRA_T] = cftsinp ;
00174 coef_t[T_SIN_I >> TRA_T] = cftsini ;
00175 coef_t[T_COSSIN_CP >> TRA_T] = cftcossincp ;
00176 coef_t[T_COSSIN_SI >> TRA_T] = cftcossinsi ;
00177 coef_t[T_COSSIN_SP >> TRA_T] = cftcossinsp ;
00178 coef_t[T_COSSIN_CI >> TRA_T] = cftcossinci ;
00179 coef_t[T_COSSIN_S >> TRA_T] = cftcossins ;
00180 coef_t[T_COSSIN_C >> TRA_T] = cftcossinc ;
00181 coef_t[T_LEG_P >> TRA_T] = cftlegp ;
00182 coef_t[T_LEG_PP >> TRA_T] = cftlegpp ;
00183 coef_t[T_LEG_I >> TRA_T] = cftlegi ;
00184 coef_t[T_LEG_IP >> TRA_T] = cftlegip ;
00185 coef_t[T_LEG_PI >> TRA_T] = cftlegpi ;
00186 coef_t[T_LEG_II >> TRA_T] = cftlegii ;
00187 coef_t[T_LEG_MP >> TRA_T] = cftlegmp ;
00188 coef_t[T_LEG_MI >> TRA_T] = cftlegmi ;
00189 coef_t[T_LEG >> TRA_T] = cftleg ;
00190
00191 coef_p[NONDEF] = base_non_def_p ;
00192 coef_p[P_COSSIN >> TRA_P] = cfpcossin ;
00193 coef_p[P_COSSIN_P >> TRA_P] = cfpcossin ;
00194 coef_p[P_COSSIN_I >> TRA_P] = cfpcossini ;
00195
00196 }
00197
00198
00199
00200
00201
00202
00203
00204 if (etat == ETATZERO) {
00205 return ;
00206 }
00207
00208
00209 assert(etat != ETATNONDEF) ;
00210
00211
00212 if (c_cf != 0x0) {
00213 return ;
00214 }
00215
00216
00217 assert(c != 0x0) ;
00218 c_cf = new Mtbl_cf(mg, base) ;
00219 c_cf->set_etat_qcq() ;
00220
00221
00222 int nz = mg->get_nzone() ;
00223 for (int l=0; l<nz; l++) {
00224
00225
00226 const Tbl* f = (c->t)[l] ;
00227 Tbl* cf = (c_cf->t)[l] ;
00228
00229 if (f->get_etat() == ETATZERO) {
00230 cf->set_etat_zero() ;
00231 continue ;
00232 }
00233
00234 cf->set_etat_qcq() ;
00235
00236 int np = f->get_dim(2) ;
00237 int nt = f->get_dim(1) ;
00238 int nr = f->get_dim(0) ;
00239
00240 int np_c = cf->get_dim(2) ;
00241 int nt_c = cf->get_dim(1) ;
00242 int nr_c = cf->get_dim(0) ;
00243
00244
00245 int deg[3] ;
00246 deg[0] = np ;
00247 deg[1] = nt ;
00248 deg[2] = nr ;
00249
00250 int dim[3] ;
00251 dim[0] = np_c ;
00252 dim[1] = nt_c ;
00253 dim[2] = nr_c ;
00254
00255 int nrnt = nr * nt ;
00256 int nrnt_c = nr_c * nt_c ;
00257
00258 for (int i=0; i<np ; i++) {
00259 for (int j=0; j<nt ; j++) {
00260 for (int k=0; k<nr ; k++) {
00261 int index = nrnt * i + nr * j + k ;
00262 int index_c = nrnt_c * i + nr_c * j + k ;
00263 (cf->t)[index_c] = (f->t)[index] ;
00264 }
00265 }
00266 }
00267
00268
00269 int base_r = ( base.b[l] & MSQ_R ) >> TRA_R ;
00270 int base_t = ( base.b[l] & MSQ_T ) >> TRA_T ;
00271 int base_p = ( base.b[l] & MSQ_P ) >> TRA_P ;
00272 int vbase_t = base.b[l] & MSQ_T ;
00273 int vbase_p = base.b[l] & MSQ_P ;
00274
00275 assert(base_r < MAX_BASE) ;
00276 assert(base_t < MAX_BASE) ;
00277 assert(base_p < MAX_BASE_2) ;
00278
00279
00280
00281 if ( np > 1 ) {
00282 assert( admissible_fft(np) ) ;
00283
00284 coef_p[base_p]( deg, dim, (cf->t) ) ;
00285 }
00286 else{
00287 for (int i=nrnt; i<3*nrnt; i++) {
00288 cf->t[i] = 0 ;
00289 }
00290 }
00291
00292
00293
00294
00295 if ( nt > 1 ) {
00296 assert( admissible_fft(nt-1) ) ;
00297 bool pair = ( (vbase_t == T_LEG_PP) || (vbase_t == T_LEG_IP)
00298 || (vbase_t == T_LEG_MP) ) ;
00299 bool impair = ( (vbase_t == T_LEG_PI) || (vbase_t == T_LEG_II)
00300 || (vbase_t == T_LEG_MI) ) ;
00301
00302 if ((pair && (vbase_p == P_COSSIN_I)) ||
00303 (impair && (vbase_p == P_COSSIN_P)) )
00304 pasprevu_t(deg, dim, (cf->t), dim, (cf->t) ) ;
00305 else
00306 coef_t[base_t](deg, dim, (cf->t), dim, (cf->t)) ;
00307 }
00308 else {
00309 if ((vbase_t == T_LEG_PP) || (vbase_t == T_LEG_PI) ||
00310 (vbase_t == T_LEG_IP) || (vbase_t == T_LEG_II) ||
00311 (vbase_t == T_LEG_P) || (vbase_t == T_LEG_I) ||
00312 (vbase_t == T_LEG) || (vbase_t == T_LEG_MP)
00313 || (vbase_t == T_LEG_MI) ) {
00314
00315 *c_cf->t[l] *=sqrt(2.) ;
00316 }
00317 }
00318
00319
00320
00321
00322 if ( nr > 1 ) {
00323 assert( admissible_fft(nr-1) ) ;
00324 coef_r[base_r](deg, dim, (cf->t), dim, (cf->t)) ;
00325 }
00326
00327 }
00328
00329 }
00330
00331
00332
00333
00334
00335 void pasprevu_r(const int*, const int*, double*, const int*, double*) {
00336 cout << "Valeur::coef: the required expansion basis in r " << endl ;
00337 cout << " is not implemented !" << endl ;
00338 abort() ;
00339 }
00340
00341 void pasprevu_t(const int*, const int*, double*, const int*, double*) {
00342 cout << "Valeur::coef: the required expansion basis in theta " << endl ;
00343 cout << " is not implemented !" << endl ;
00344 abort() ;
00345 }
00346
00347 void pasprevu_p(const int*, const int*, double*) {
00348 cout << "Valeur::coef: the required expansion basis in phi " << endl ;
00349 cout << " is not implemented !" << endl ;
00350 abort() ;
00351 }
00352
00353 void base_non_def_r(const int*, const int*, double*, const int*, double*) {
00354 cout << "Valeur::coef: the expansion basis in r is undefined !" << endl ;
00355 abort() ;
00356 }
00357
00358 void base_non_def_t(const int*, const int*, double*, const int*, double*) {
00359 cout << "Valeur::coef: the expansion basis in theta is undefined !" << endl ;
00360 abort() ;
00361 }
00362
00363 void base_non_def_p(const int*, const int*, double*) {
00364 cout << "Valeur::coef: the expansion basis in phi is undefined !" << endl ;
00365 abort() ;
00366 }
00367