00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 char comb_lin_cpt_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/comb_lin_cpt.C,v 1.2 2002/10/16 14:37:11 j_novak Exp $" ;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include <stdlib.h>
00049
00050
00051 #include "matrice.h"
00052
00053
00054
00055
00056
00057
00058
00059
00060 Matrice _cl_cpt_pas_prevu (const Matrice &source, int) {
00061 cout << "Combinaison lineaire pas prevu..." << endl ;
00062 cout << "Source : " << source << endl ;
00063 abort() ;
00064 return source;
00065 }
00066
00067
00068
00069
00070
00071
00072
00073 Matrice _cl_cpt_r_chebp (const Matrice &source, int) {
00074
00075 int n = source.get_dim(0) ;
00076 assert (n == source.get_dim(1)) ;
00077
00078 Matrice barre(source) ;
00079 int dirac = 1 ;
00080 for (int i=0 ; i<n-2 ; i++) {
00081 for (int j=0 ; j<n ; j++)
00082 barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j))/(i+1) ;
00083 if (i==0) dirac = 0 ;
00084 }
00085
00086 Matrice res(barre) ;
00087 for (int i=0 ; i<n-4 ; i++)
00088 for (int j=0 ; j<n ; j++)
00089 res.set(i, j) = barre(i, j)-barre(i+2, j) ;
00090
00091 res.set_band(4, 1) ;
00092 res.set_lu() ;
00093 return res ;
00094 }
00095
00096
00097
00098
00099
00100
00101 Matrice _cl_cpt_r_chebi (const Matrice &source, int l) {
00102 int n = source.get_dim(0) ;
00103 assert (n == source.get_dim(1)) ;
00104
00105 Matrice barre(source) ;
00106 for (int i=0 ; i<n-2 ; i++)
00107 for (int j=0 ; j<n ; j++)
00108 barre.set(i, j) = (source(i, j)-source(i+1, j))/(i+1) ;
00109
00110 Matrice res(barre) ;
00111 for (int i=0 ; i<n-4 ; i++)
00112 for (int j=0 ; j<n ; j++)
00113 res.set(i, j) = barre(i, j)-barre(i+2, j) ;
00114
00115 if (l==1)
00116 res.set_band(3, 0) ;
00117 else
00118 res.set_band(3, 1) ;
00119 res.set_lu() ;
00120 return res ;
00121
00122 }
00123
00124
00125
00126
00127
00128
00129 Matrice combinaison_cpt (const Matrice &source, int l, int base_r) {
00130
00131
00132 static Matrice (*combinaison_cpt[MAX_BASE])
00133 (const Matrice &, int) ;
00134 static int nap = 0 ;
00135
00136
00137 if (nap==0) {
00138 nap = 1 ;
00139 for (int i=0 ; i<MAX_BASE ; i++) {
00140 combinaison_cpt[i] = _cl_cpt_pas_prevu ;
00141 }
00142
00143 combinaison_cpt[R_CHEBP >> TRA_R] = _cl_cpt_r_chebp ;
00144 combinaison_cpt[R_CHEBI >> TRA_R] = _cl_cpt_r_chebi ;
00145 }
00146
00147 Matrice res(combinaison_cpt[base_r](source, l)) ;
00148 return res ;
00149 }
00150
00151
00152
00153
00154
00155
00156
00157 Tbl _cl_cpt_pas_prevu(const Tbl& tb) {
00158 cout << "combinaison_nul_pas_prevu " << endl ;
00159 cout << "tb : " << tb << endl ;
00160 abort() ;
00161 return tb ;
00162 }
00163
00164
00165
00166
00167
00168 Tbl _cl_cpt_r_chebp(const Tbl& tb) {
00169
00170 assert (tb.get_etat() != ETATNONDEF) ;
00171 int n=tb.get_dim(0) ;
00172
00173 Tbl barre(tb) ;
00174 int dirac = 1 ;
00175 for (int i=0 ; i<n-2 ; i++) {
00176 barre.set(i) = ((1+dirac)*tb(i)-tb(i+2))/(i+1) ;
00177 if (i==0) dirac = 0 ;
00178 }
00179
00180 Tbl res(barre) ;
00181 for (int i=0 ; i<n-4 ; i++)
00182 res.set(i) = barre(i)-barre(i+2) ;
00183
00184 return res ;
00185 }
00186
00187
00188
00189
00190
00191
00192 Tbl _cl_cpt_r_chebi(const Tbl& tb) {
00193
00194 assert (tb.get_etat() != ETATNONDEF) ;
00195 int n=tb.get_dim(0) ;
00196
00197 Tbl barre(tb) ;
00198 for (int i=0 ; i<n-2 ; i++)
00199 barre.set(i) = (tb(i)-tb(i+1))/(i+1) ;
00200
00201 Tbl res(barre) ;
00202 for (int i=0 ; i<n-4 ; i++)
00203 res.set(i) = barre(i)-barre(i+2) ;
00204
00205 return res ;
00206 }
00207
00208
00209
00210
00211
00212
00213 Tbl combinaison_cpt (const Tbl &source, int base_r) {
00214
00215
00216 static Tbl (*combinaison_cpt[MAX_BASE])(const Tbl&) ;
00217 static int nap = 0 ;
00218
00219
00220 if (nap==0) {
00221 nap = 1 ;
00222 for (int i=0 ; i<MAX_BASE ; i++) {
00223 combinaison_cpt[i] = _cl_cpt_pas_prevu ;
00224 }
00225
00226 combinaison_cpt[R_CHEBP >> TRA_R] = _cl_cpt_r_chebp ;
00227 combinaison_cpt[R_CHEBI >> TRA_R] = _cl_cpt_r_chebi ;
00228 }
00229
00230 Tbl res(combinaison_cpt[base_r](source)) ;
00231 return res ;
00232 }
00233