00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 char multx2_1d_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/multx2_1d.C,v 1.2 2002/10/16 14:36:58 j_novak Exp $" ;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include <stdlib.h>
00045 #include <assert.h>
00046
00047 #include "headcpp.h"
00048 #include "type_parite.h"
00049 #include "proto.h"
00050
00051
00052
00053
00054
00055 void _multx2_1d_pas_prevu(int nr, double* tb, double *res) {
00056 cout << "multx2 pas prevu..." << tb << " " << res << endl ;
00057 cout << "nr : " << nr << endl ;
00058 abort() ;
00059 exit(-1) ;
00060 }
00061
00062
00063
00064
00065
00066 void _multx2_1d_r_chebp(int nr, double* tb, double *xo) {
00067
00068 assert (nr>2) ;
00069
00070 xo[0] = (2*tb[0]+tb[1])/4 ;
00071 xo[1] = (2*tb[0]+2*tb[1]+tb[2])/4 ;
00072
00073 for (int i=2 ; i<nr-1 ; i++)
00074 xo[i] = (tb[i-1]+2*tb[i]+tb[i+1])/4 ;
00075 xo[nr-1] = (tb[nr-2]+2*tb[nr-1])/4 ;
00076 }
00077
00078
00079
00080
00081
00082
00083 void _multx2_1d_r_chebi(int nr, double* tb, double *xo){
00084 assert(nr>1) ;
00085 xo[0] = (3*tb[0]+tb[1])/4 ;
00086 for (int i=1 ; i<nr-1 ; i++)
00087 xo[i] = (tb[i-1]+2*tb[i]+tb[i+1])/4 ;
00088 xo[nr-1] = (tb[nr-2]+2*tb[nr-1])/4 ;
00089 }
00090
00091
00092
00093
00094
00095 void _multx2_1d_r_cheb(int nr, double* tb, double *xo){
00096 assert(nr>3) ;
00097 xo[0] = (2*tb[0]+tb[2])/4 ;
00098 xo[1] = (3*tb[1]+tb[3])/4 ;
00099 xo[2] = (2*tb[0]+2*tb[2]+tb[4])/4 ;
00100 for (int i=3 ; i<nr-2 ; i++)
00101 xo[i] = (tb[i-2]+2*tb[i]+tb[i+2])/4 ;
00102 for (int i=nr-2 ; i<nr ; i++)
00103 xo[i] = (tb[i-2]+2*tb[i])/4 ;
00104 }
00105
00106
00107
00108
00109
00110
00111
00112
00113 void multx2_1d(int nr, double **tb, int base_r)
00114 {
00115
00116
00117 static void (*multx2_1d[MAX_BASE])(int, double *, double*) ;
00118 static int nap = 0 ;
00119
00120
00121 if (nap==0) {
00122 nap = 1 ;
00123 for (int i=0 ; i<MAX_BASE ; i++) {
00124 multx2_1d[i] = _multx2_1d_pas_prevu ;
00125 }
00126
00127 multx2_1d[R_CHEB >> TRA_R] = _multx2_1d_r_cheb ;
00128 multx2_1d[R_CHEBP >> TRA_R] = _multx2_1d_r_chebp ;
00129 multx2_1d[R_CHEBI >> TRA_R] = _multx2_1d_r_chebi ;
00130 }
00131
00132 double *result = new double[nr] ;
00133 multx2_1d[base_r](nr, *tb, result) ;
00134
00135 delete [] (*tb) ;
00136 (*tb) = result ;
00137 }