#ifndef GRID_CHEBYSHEV_H #define GRID_CHEBYSHEV_H #include #include namespace Grid { //////////////////////////////////////////////////////////////////////////////////////////// // Simple general polynomial with user supplied coefficients //////////////////////////////////////////////////////////////////////////////////////////// template class Polynomial : public OperatorFunction { private: std::vector Coeffs; public: Polynomial(std::vector &_Coeffs) : Coeffs(_Coeffs) {}; // Implement the required interface void operator() (LinearOperatorBase &Linop, const Field &in, Field &out) { Field AtoN = in; out = AtoN*Coeffs[0]; for(int n=1;n class Chebyshev : public OperatorFunction { private: std::vector Coeffs; int order; double hi; double lo; public: void csv(std::ostream &out){ for (double x=lo; x U(M); std::vector a(M); std::vector g(M); for(int n=0;n<=M;n++){ U[n] = std::sin((n+1)*std::acos(lmax))/std::sin(std::acos(lmax)); sumUsq += U[n]*U[n]; } sumUsq = std::sqrt(sumUsq); for(int i=1;i<=M;i++){ a[i] = U[i]/sumUsq; } g[0] = 1.0; for(int m=1;m<=M;m++){ g[m] = 0; for(int i=0;i<=M-m;i++){ g[m]+= a[i]*a[m+i]; } } for(int m=1;m<=M;m++){ Coeffs[m]*=g[m]; } } double approx(double x) // Convenience for plotting the approximation { double Tn; double Tnm; double Tnp; double y=( x-0.5*(hi+lo))/(0.5*(hi-lo)); double T0=1; double T1=y; double sum; sum = 0.5*Coeffs[0]*T0; sum+= Coeffs[1]*T1; Tn =T1; Tnm=T0; for(int i=2;i &Linop, const Field &in, Field &out) { GridBase *grid=in._grid; int vol=grid->gSites(); Field T0(grid); T0 = in; Field T1(grid); Field T2(grid); Field y(grid); Field *Tnm = &T0; Field *Tn = &T1; Field *Tnp = &T2; std::cout<