#include #include using namespace std; using namespace Grid; using namespace Grid::QCD; static int FEenableexcept (unsigned int excepts) { static fenv_t fenv; unsigned int new_excepts = excepts & FE_ALL_EXCEPT, old_excepts; // previous masks if ( fegetenv (&fenv) ) return -1; old_excepts = fenv.__control & FE_ALL_EXCEPT; // unmask fenv.__control &= ~new_excepts; fenv.__mxcsr &= ~(new_excepts << 7); return ( fesetenv (&fenv) ? -1 : old_excepts ); } template class DumbOperator : public LinearOperatorBase { public: LatticeComplex scale; DumbOperator(GridBase *grid) : scale(grid) { GridParallelRNG pRNG(grid); std::vector seeds({5,6,7,8}); pRNG.SeedFixedIntegers(seeds); random(pRNG,scale); scale = exp(-real(scale)*6.0); std::cout << " True matrix \n"<< scale < seeds({1,2,3,4}); RNG.SeedFixedIntegers(seeds); RealD alpha = 1.0; RealD beta = 0.03; RealD mu = 0.0; int order = 11; ChebyshevLanczos Cheby(alpha,beta,mu,order); std::ofstream file("pooh.dat"); Cheby.csv(file); HermOpOperatorFunction X; DumbOperator HermOp(grid); const int Nk = 40; const int Nm = 80; const int Nit= 10000; int Nconv; RealD eresid = 1.0e-8; ImplicitlyRestartedLanczos IRL(HermOp,X,Nk,Nm,eresid,Nit); ImplicitlyRestartedLanczos ChebyIRL(HermOp,Cheby,Nk,Nm,eresid,Nit); LatticeComplex src(grid); gaussian(RNG,src); { std::vector eval(Nm); std::vector evec(Nm,grid); IRL.calc(eval,evec,src, Nconv); } { std::vector eval(Nm); std::vector evec(Nm,grid); ChebyIRL.calc(eval,evec,src, Nconv); } Grid_finalize(); }