20 #include "base_spectral.hpp"
21 #include "headcpp.hpp"
22 #include "matrice.hpp"
25 int div_1mx2_1d_pasprevu (Array<double>&) {
26 cout <<
"div_1mx2_1d not implemented." << endl ;
31 int div_1mx2_1d_cheb (Array<double>& so) {
32 assert (so.get_ndim()==1) ;
33 int nr = so.get_size(0) ;
34 Array<double> res (nr) ;
36 for (
int n=0 ; n<nr ; n++)
37 for (
int p=n+2 ; p<nr ; p+=2)
38 res.set(n) += -2*(p-n)*so(p) ;
45 int div_1mx2_1d_cheb_even (Array<double>& so) {
46 assert (so.get_ndim()==1) ;
47 int nr = so.get_size(0) ;
48 Array<double> res (nr) ;
50 for (
int n=0 ; n<nr ; n++)
51 for (
int p=n+1 ; p<nr ; p++)
52 res.set(n) += -4*(p-n)*so(p) ;
59 int div_1mx2_1d_cheb_odd (Array<double>& so) {
60 assert (so.get_ndim()==1) ;
61 int nr = so.get_size(0) ;
62 Array<double> res (nr) ;
64 for (
int n=0 ; n<nr ; n++)
65 for (
int p=n+1 ; p<nr ; p++)
66 res.set(n) += -4*(p-n)*so(p) ;
72 int div_1mx2_1d (
int base, Array<double>& so) {
73 static int (*div_1mx2_1d[NBR_MAX_BASE])(Array<double>&) ;
74 static bool premier_appel = true ;
78 premier_appel = false ;
80 for (
int i=0; i<NBR_MAX_BASE; i++)
81 div_1mx2_1d[i] = div_1mx2_1d_pasprevu ;
83 div_1mx2_1d[CHEB] = div_1mx2_1d_cheb ;
84 div_1mx2_1d[CHEB_EVEN] = div_1mx2_1d_cheb_even ;
85 div_1mx2_1d[CHEB_ODD] = div_1mx2_1d_cheb_odd ;
88 return div_1mx2_1d[base](so) ;