18 #define GREGORY_KMAX 8 19 void read_poly_interpolation(
int k,
long double *P);
20 void read_poly_differentiation(
int k,
long double *w);
21 void read_poly_integration(
int k,
long double *w);
22 void read_poly_interpolation(
int k,
double *P);
23 void read_poly_differentiation(
int k,
double *P);
24 void read_poly_integration(
int k,
double *P);
25 void read_poly_interpolation(
int k,
float *P);
26 void read_poly_differentiation(
int k,
float *P);
27 void read_poly_integration(
int k,
float *P);
28 void read_gregory_weights(
int k,
double *w);
29 void read_bd_weights(
int k,
double *w);
30 void read_rcorr(
int k,
double *w);
149 if(k<0 || k > GREGORY_KMAX ){ std::cout <<
"Integrator: k out of range " << std::endl; abort();}
150 poly_interpolation_=
new T [k1*k1];
151 poly_differentiation_=
new T [k1*k1];
152 poly_integration_=
new T [k1*k1*k1];
153 bd_weights_=
new T [k1+1];
154 gregory_weights_=
new T [ 4*k1*k1 ];
155 gregory_omega_=gregory_weights_ + ((2*
k+1)*2*k1);
156 if(
k>1) rcorr_ =
new T [ (
k-1)*k1*k1] ;
else rcorr_=0;
158 integration::read_poly_interpolation(k_,poly_interpolation_);
159 integration::read_poly_differentiation(k_,poly_differentiation_);
160 integration::read_poly_integration(k_,poly_integration_);
161 integration::read_bd_weights(
k+1,bd_weights_);
162 integration::read_gregory_weights(
k,gregory_weights_);
163 integration::read_rcorr(k_,rcorr_);
167 if( this->k_==
I.k_ )
return *
this;
168 delete [] poly_interpolation_;
169 delete [] poly_differentiation_;
170 delete [] poly_integration_;
171 delete [] bd_weights_;
172 delete [] gregory_weights_;
176 poly_interpolation_=
new T [k1*k1];
177 poly_differentiation_=
new T [k1*k1];
178 poly_integration_=
new T [k1*k1*k1];
179 bd_weights_=
new T [k1+1];
180 gregory_weights_=
new T [ 4*k1*k1 ];
181 gregory_omega_=gregory_weights_ + ((2*k_+1)*2*k1);
182 if(k_>1) rcorr_ =
new T [ (k_-1)*k1*k1] ;
else rcorr_=0;
183 integration::read_poly_interpolation(k_,poly_interpolation_);
184 integration::read_poly_differentiation(k_,poly_differentiation_);
185 integration::read_poly_integration(k_,poly_integration_);
186 integration::read_bd_weights(k_+1,bd_weights_);
187 integration::read_gregory_weights(k_,gregory_weights_);
188 integration::read_rcorr(k_,rcorr_);
192 delete [] poly_interpolation_;
193 delete [] poly_differentiation_;
194 delete [] poly_integration_;
195 delete [] bd_weights_;
196 delete [] gregory_weights_;
203 poly_interpolation_=
new T [k1*k1];
204 poly_differentiation_=
new T [k1*k1];
205 poly_integration_=
new T [k1*k1*k1];
206 bd_weights_=
new T [k1+1];
207 gregory_weights_=
new T [ 4*k1*k1 ];
208 gregory_omega_=gregory_weights_ + ((2*k_+1)*2*k1);
209 if(k_>1) rcorr_ =
new T [ (k_-1)*k1*k1] ;
else rcorr_=0;
210 integration::read_poly_interpolation(k_,poly_interpolation_);
211 integration::read_poly_differentiation(k_,poly_differentiation_);
212 integration::read_poly_integration(k_,poly_integration_);
213 integration::read_bd_weights(k_+1,bd_weights_);
214 integration::read_gregory_weights(k_,gregory_weights_);
215 integration::read_rcorr(k_,rcorr_);
236 int k(
void) {
return k_;}
321 T
poly_integration(
int i,
int j,
int l) {
return poly_integration_[i*(k_+1)*(k_+1) + j*(k_+1) + l];}
384 assert( j>=0 && ( j<=k_ || j<=n) );
386 if( j > k_ && j < n-k_ ) {
return 1;}
387 else if ( j<k1 ) {
return gregory_omega_[j];}
388 else {
return gregory_omega_[n-j]; }
389 }
else{
return gregory_weights_[n*k2 + j];}
442 assert(m<k_ && j<=k_ && l<=k_);
443 return *(rcorr_ + (m-1)*k1*k1 + j*k1 +l);
474 template <
class M> M
integrate(
const std::vector<M> &f,
int n){
475 int k1=k_+1,i,k2=2*k1,n1=n-k_;
481 assert(
int(f.size()) >= n1);
485 for(i=0;i<=k_;i++) sum += f[i]*gregory_omega_[i];
486 for(i=k1;i<n1;i++) sum += f[i];
487 for(i=n1;i<=n;i++) sum += f[i]*gregory_omega_[n-i];
489 w=gregory_weights_ + n*k2;
490 for(i=0;i<=n1;i++) sum += f[i]*w[i];
497 T *poly_interpolation_;
498 T *poly_differentiation_;
499 T *poly_integration_;
511 for(
int k=1;k<=5;k++) Isave[k]=Integrator<T>(k);
516 #ifndef CNTR_NO_EXTERN_TEMPLATES 517 extern template class Integrator<double>;
518 extern template Integrator<double> &
I<double>(
int k);
Class Integrator contains all kinds of weights for integration and differentiation of a function at ...
T rcorr(int m, int j, int l)
Returns the special quadrature weights for computing integrals on the Matsubara axis.
int get_k(void)
Returns the order of the integrator class.
Integrator(int k=0)
Initializes the Integrator class for a given order k.
Integrator< T > & I(int k)
T gregory_omega(int j)
Returns the Gregory weights at the integral boundaries (see gregory_weights).
T poly_integration(int i, int j, int l)
Returns the the weight needed for polynomial integration.
T gregory_weights(int n, int j)
Returns the Gregory weights for integration.
T bd_weights(int l)
Returns the the backwards differencing coefficients.
T poly_interpolation(int alpha, int l)
Returns the the weight needed for polynomial interpolation.
T poly_differentiation(int i, int l)
Returns the the weight needed for polynomial differentiation.
int k(void)
Returns the order of the integrator class.
template Integrator< double > & I< double >(int k)
Integrator & operator=(const Integrator &I)
M integrate(const std::vector< M > &f, int n)
Integrates a function using Gregory quadrature.
Integrator(const Integrator &I)