21 #include "base_spectral.hpp"
24 double integral_1d_pasprevu (
const Array<double>&) {
25 cout <<
"Integral_1d not implemented." << endl ;
29 double integral_1d_cos_even (
const Array<double>& so) {
33 double integral_1d_sin_odd (
const Array<double>& so) {
34 int nn = so.get_size(0) ;
36 for (
int i=0 ; i<nn ; i++)
37 res += so(i)*2./(2.*i+1) ;
41 double integral_1d_sin_even (
const Array<double>&) {
45 double integral_1d_cos_odd (
const Array<double>&) {
49 double integral_1d_cheb_even (
const Array<double>& so) {
50 int nn = so.get_size(0) ;
52 for (
int i=0 ; i<nn ; i++)
53 res += -so(i)/(4.*i*i-1) ;
56 double integral_1d_cheb (
const Array<double>& so) {
57 int nn = so.get_size(0) ;
59 for (
int i=0 ; i<nn ; i+=2)
60 res += -2*so(i)/(i*i-1.) ;
64 double integral_1d (
int base,
const Array<double>& tab) {
66 static double (*integral_1d[NBR_MAX_BASE])(
const Array<double>&) ;
67 static bool premier_appel = true ;
70 premier_appel = false ;
72 for (
int i=0; i<NBR_MAX_BASE; i++)
73 integral_1d[i] = integral_1d_pasprevu ;
75 integral_1d[COS_EVEN] = integral_1d_cos_even ;
76 integral_1d[COS_ODD] = integral_1d_cos_odd ;
77 integral_1d[SIN_ODD] = integral_1d_sin_odd ;
78 integral_1d[SIN_EVEN] = integral_1d_sin_even ;
79 integral_1d[CHEB_EVEN] = integral_1d_cheb_even ;
80 integral_1d[CHEB] = integral_1d_cheb ;
83 return integral_1d[base](tab) ;