67 #include "type_parite.h" 76 Matrice _helmholtz_minus_mat_pas_prevu(
int,
int,
double,
double,
double) {
77 cout <<
"Helmholtz minus : base not implemented..." << endl ;
88 Matrice _helmholtz_minus_mat_r_chebu (
int n,
int lq,
double alpha,
89 double,
double masse) {
93 Matrice res(n-2, n-2) ;
96 double* vect =
new double[n] ;
97 double* vect_bis =
new double[n] ;
98 double* vect_dd =
new double[n] ;
100 for (
int i=0 ; i<n-2 ; i++) {
102 for (
int j=0 ; j<n ; j++)
108 for (
int j=0 ; j<n ; j++)
109 vect_bis[j] = vect[j] ;
111 d2sdx2_1d (n, &vect_bis,
R_CHEBU) ;
112 mult2_xm1_1d_cheb (n, vect_bis, vect_dd) ;
115 for (
int j=0 ; j<n ; j++)
116 vect_bis[j] = vect[j] ;
117 sx2_1d (n, &vect_bis,
R_CHEBU) ;
119 for (
int j=0 ; j<n-2 ; j++)
120 res.set(j,i) = vect_dd[j] - lq*(lq+1)*vect[j]
121 - masse*masse*vect_bis[j]/alpha/alpha ;
136 Matrice _helmholtz_minus_mat_r_cheb (
int n,
int lq,
double alpha,
double beta,
141 double echelle = beta / alpha ;
150 double* vect =
new double[n] ;
152 for (
int i=0 ; i<n ; i++) {
153 for (
int j=0 ; j<n ; j++)
156 d2sdx2_1d (n, &vect,
R_CHEB) ;
157 vect[i] -= masse*masse*alpha*alpha ;
158 for (
int j=0 ; j<n ; j++)
159 dd.set(j, i) = vect[j]*echelle*echelle ;
162 for (
int i=0 ; i<n ; i++) {
163 for (
int j=0 ; j<n ; j++)
166 d2sdx2_1d (n, &vect,
R_CHEB) ;
167 vect[i] -= masse*masse*alpha*alpha ;
168 multx_1d (n, &vect,
R_CHEB) ;
169 for (
int j=0 ; j<n ; j++)
170 dd.set(j, i) += 2*echelle*vect[j] ;
173 for (
int i=0 ; i<n ; i++) {
174 for (
int j=0 ; j<n ; j++)
177 d2sdx2_1d (n, &vect,
R_CHEB) ;
178 vect[i] -= masse*masse*alpha*alpha ;
179 multx_1d (n, &vect,
R_CHEB) ;
180 multx_1d (n, &vect,
R_CHEB) ;
181 for (
int j=0 ; j<n ; j++)
182 dd.set(j, i) += vect[j] ;
185 for (
int i=0 ; i<n ; i++) {
186 for (
int j=0 ; j<n ; j++)
189 sxdsdx_1d (n, &vect,
R_CHEB) ;
190 for (
int j=0 ; j<n ; j++)
191 xd.set(j, i) = vect[j]*echelle ;
194 for (
int i=0 ; i<n ; i++) {
195 for (
int j=0 ; j<n ; j++)
198 sxdsdx_1d (n, &vect,
R_CHEB) ;
199 multx_1d (n, &vect,
R_CHEB) ;
200 for (
int j=0 ; j<n ; j++)
201 xd.set(j, i) += vect[j] ;
204 for (
int i=0 ; i<n ; i++) {
205 for (
int j=0 ; j<n ; j++)
208 sx2_1d (n, &vect,
R_CHEB) ;
209 for (
int j=0 ; j<n ; j++)
210 xx.set(j, i) = vect[j] ;
216 res = dd+2*xd - lq*(lq+1)*xx;
227 Matrice _helmholtz_minus_mat_r_chebp (
int n,
int lq,
double alpha,
double,
double masse) {
234 return Matrice(d2 + 2.*sxd -masse*masse*alpha*alpha*xx) ;
237 Matrice res(n-1, n-1) ;
240 double* vect =
new double[n] ;
242 double* vect_sx2 =
new double[n] ;
243 double* vect_sxd =
new double[n] ;
244 double* vect_dd =
new double[n] ;
246 for (
int i=0 ; i<n-1 ; i++) {
247 for (
int j=0 ; j<n ; j++)
253 for (
int j=0 ; j<n ; j++)
254 vect_dd[j] = vect[j] ;
255 d2sdx2_1d (n, &vect_dd,
R_CHEBP) ;
256 for (
int j=0 ; j<n ; j++)
257 vect_sxd[j] = vect[j] ;
258 sxdsdx_1d (n, &vect_sxd,
R_CHEBP) ;
259 for (
int j=0 ; j<n ; j++)
260 vect_sx2[j] = vect[j] ;
261 sx2_1d (n, &vect_sx2,
R_CHEBP) ;
263 for (
int j=0 ; j<n-1 ; j++)
264 res.set(j,i) = vect_dd[j] +2*vect_sxd[j] - lq*(lq+1)*vect_sx2[j] - masse*masse*alpha*alpha*vect[j] ;
282 Matrice _helmholtz_minus_mat_r_chebi (
int n,
int lq,
double alpha,
double,
double masse) {
290 return Matrice(d2 + 2.*sxd - (lq*(lq+1))*sx2- masse*masse*alpha*alpha*xx) ;
293 Matrice res(n-1, n-1) ;
296 double* vect =
new double[n] ;
298 double* vect_sx2 =
new double[n] ;
299 double* vect_sxd =
new double[n] ;
300 double* vect_dd =
new double[n] ;
302 for (
int i=0 ; i<n-1 ; i++) {
303 for (
int j=0 ; j<n ; j++)
306 vect[i+1] = (2*i+1) ;
309 for (
int j=0 ; j<n ; j++)
310 vect_dd[j] = vect[j] ;
311 d2sdx2_1d (n, &vect_dd,
R_CHEBI) ;
312 for (
int j=0 ; j<n ; j++)
313 vect_sxd[j] = vect[j] ;
314 sxdsdx_1d (n, &vect_sxd,
R_CHEBI) ;
315 for (
int j=0 ; j<n ; j++)
316 vect_sx2[j] = vect[j] ;
317 sx2_1d (n, &vect_sx2,
R_CHEBI) ;
319 for (
int j=0 ; j<n-1 ; j++)
320 res.set(j,i) = vect_dd[j] +2*vect_sxd[j] - lq*(lq+1)*vect_sx2[j] - masse*masse*alpha*alpha*vect[j] ;
337 Matrice helmholtz_minus_mat(
int n,
int lq,
338 double alpha,
double beta,
double masse,
343 static Matrice (*helmholtz_minus_mat[
MAX_BASE])(int, int,
344 double, double, double);
351 helmholtz_minus_mat[i] = _helmholtz_minus_mat_pas_prevu ;
354 helmholtz_minus_mat[
R_CHEB >>
TRA_R] = _helmholtz_minus_mat_r_cheb ;
355 helmholtz_minus_mat[
R_CHEBU >>
TRA_R] = _helmholtz_minus_mat_r_chebu ;
356 helmholtz_minus_mat[
R_CHEBP >>
TRA_R] = _helmholtz_minus_mat_r_chebp ;
357 helmholtz_minus_mat[
R_CHEBI >>
TRA_R] = _helmholtz_minus_mat_r_chebi ;
360 Matrice res(helmholtz_minus_mat[base_r](n, lq, alpha, beta, masse)) ;
#define TRA_R
Translation en R, used for a bitwise shift (in hex)
#define R_CHEBI
base de Cheb. impaire (rare) seulement
#define R_CHEBP
base de Cheb. paire (rare) seulement
#define R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
#define MAX_BASE
Nombre max. de bases differentes.
#define R_CHEB
base de Chebychev ordinaire (fin)