7 #include "qdp-lapack_Complex.h"
8 #include "qdp-lapack_eigpcg.h"
9 #include "qdp-lapack_IncrEigpcg.h"
22 namespace MdagMSysSolverOptEigCGEnv
27 Handle<
FermState< LatticeFermion, multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > >
state,
76 void MatrixMatvec(
void *
x,
void *
y,
void *
params) {
78 MatVecArg<T> &arg = *((MatVecArg<T> *)
params) ;
81 RComplex<float> *px = (RComplex<float> *)
x;
82 RComplex<float> *py = (RComplex<float> *)
y;
89 Subset
s = arg.MdagM->subset() ;
90 if(
s.hasOrderedRep()){
102 for(
int i=
s.start();
i <=
s.end();
i++)
103 for(
int ss(0);ss<Ns;ss++)
104 for(
int c(0);
c<Nc;
c++){
105 arg.XX.elem(
i).elem(ss).elem(
c) = *(px+
count);
112 const int *tab =
s.siteTable().slice();
114 for(
int x=0;
x <
s.numSiteTable(); ++
x){
116 for(
int ss(0);ss<Ns;ss++)
117 for(
int c(0);
c<Nc;
c++){
118 arg.XX.elem(
i).elem(ss).elem(
c) = *(px+
count);
125 (*arg.MdagM)(arg.YY,arg.XX,
PLUS) ;
130 if(
s.hasOrderedRep()){
133 for(
int i=
s.start();
i <=
s.end();
i++)
134 for(
int ss(0);ss<Ns;ss++)
135 for(
int c(0);
c<Nc;
c++){
136 *(py+
count) = arg.YY.elem(
i).elem(ss).elem(
c) ;
143 const int *tab =
s.siteTable().slice();
144 for(
int x=0;
x <
s.numSiteTable(); ++
x){
146 for(
int ss(0);ss<Ns;ss++)
147 for(
int c(0);
c<Nc;
c++){
148 *(py+
count) = arg.YY.elem(
i).elem(ss).elem(
c) ;
168 #ifndef QDP_IS_QDPJIT
175 QDPIO::cout<<
"EigInfo.N= "<<
EigInfo.N<<std::endl ;
176 QDPIO::cout<<
"EigInfo.lde= "<<
EigInfo.
lde<<std::endl ;
177 QDPIO::cout<<
"EigInfo.ldh= "<<
EigInfo.
evals.size()<<std::endl ;
181 Subset
s =
A.subset() ;
185 Complex_C *work=NULL ;
187 Complex_C *ework=NULL ;
194 typename SinglePrecType<T>::Type_t psif =
psi;
195 typename SinglePrecType<T>::Type_t chif =
chi;
197 if(
s.hasOrderedRep()){
198 X = (Complex_C *) &psif.elem(
s.start()).elem(0).elem(0).real();
199 B = (Complex_C *) &chif.elem(
s.start()).elem(0).elem(0).real();
204 QDPIO::cout<<
"OPPS! I have not implemented OPT_EigCG for Linops with non contigius subset\n";
210 Complex_C *H = (Complex_C *) &
EigInfo.
H[0] ;
211 Complex_C *HU = (Complex_C *) &
EigInfo.
HU[0] ;
214 int esize = invParam.
esize*Layout::sitesOnNode()*Nc*Ns ;
216 QDPIO::cout<<
"OPT_EIGCG_SYSSOLVER= "<<esize<<std::endl ;
218 float resid = (float) invParam.
RsdCG.elem().elem().elem().elem();
219 float AnormEst = invParam.
NormAest.elem().elem().elem().elem();
226 restartTol = invParam.
restartTol.elem().elem().elem().elem();
234 MatrixMatvec<T>, NULL, (
void *)&arg, work, V,
239 invParam.
Neig, invParam.
Nmax, stdout);
249 QDPIO::cout<<
"OPT_EICG_SYSSOLVER: True residual after solution : "<<sqrt(norm2(tt-
chi,
s))<<std::endl ;
250 QDPIO::cout<<
"OPT_EICG_SYSSOLVER: norm of solution : "<<sqrt(norm2(
psi,
s))<<std::endl ;
251 QDPIO::cout<<
"OPT_EICG_SYSSOLVER: norm of rhs : "<<sqrt(norm2(
chi,
s))<<std::endl ;
255 if(!
s.hasOrderedRep()){
256 QDPIO::cout<<
"OPPS! I have no implemented OPT_EigCG for Linops with non contigius subset\n";
265 res.
resid = Real(1000000);
266 QDPIO::cout <<
"This solver is not implemented over QDP-JIT." << std::endl;
Support class for fermion actions and linear operators.
Class for counted reference semantics.
multi1d< LatticeFermion > evecs
Solve a M*psi=chi linear system by CG2 with eigenvectors.
SystemSolverResults_t operator()(T &psi, const T &chi) const
Solver the linear system.
LinOpSystemSolver< LatticeStaggeredFermion > * createStagFerm(XMLReader &xml_in, const std::string &path, Handle< LinearOperator< LatticeStaggeredFermion > > A)
Callback function.
bool registerAll()
Register all the factories.
MdagMSystemSolver< LatticeFermion > * createFerm(XMLReader &xml_in, const std::string &path, Handle< FermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > state, Handle< LinearOperator< LatticeFermion > > A)
Callback function.
static bool registered
Local registration flag.
const std::string name("EIG_CG_INVERTER")
Name to be used.
Asqtad Staggered-Dirac operator.
LinOpSysSolverMGProtoClover::T T
multi1d< LatticeFermion > chi(Ncb)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
multi1d< LatticeFermion > s(Ncb)
Params for EigCG inverter.
Holds return info from SystemSolver call.
Handle< LinearOperator< T > > MdagM
Solve a M^dag*M*psi=chi linear system by EigCG.
Register MdagM system solvers.
Factory for producing system solvers for MdagM*psi = chi.