42 multi1d<Real>& lambda_H,
43 multi1d<LatticeFermion>&
psi,
51 const Real& zero_cutoff,
61 const Subset& sub = M.
subset();
63 push(xml_out,
"EigSpecRitzCG");
73 multi1d<Real> resid_rel(n_eig);
74 for(
n = 1,
i = 0;
n <= n_eig;
n++,
i++) {
77 lambda_H[
i] = Real(1);
80 Ritz(M, lambda_H[
i],
psi,
n, Rsd_r, Rsd_a, zero_cutoff, n_renorm, n_min,
81 n_max,
MaxCG, ProjApsiP,
n_count, final_grad,
false, Real(1),
90 push(xml_out,
s.str());
94 if( toBool( fabs(lambda_H[
i]) < zero_cutoff ) )
96 QDPIO::cout <<
"Evalue["<<
n <<
"] = " << lambda_H[
i] <<
" is considered zero" << std::endl;
101 LatticeFermion lambda_e;
103 lambda_e[sub] = lambda_H[
i]*
psi[
i];
104 D_e[sub] -= lambda_e;
106 resid_rel[
i] = Real(
r_norm)/lambda_H[
i];
107 QDPIO::cout <<
"Evalue["<<
n<<
"]: eigen_norm = " <<
r_norm <<
" resid_rel = " << resid_rel[
i] << std::endl << std::endl;
112 push(xml_out,
"eValues");
113 write(xml_out,
"lambda", lambda_H);
115 write(xml_out,
"n_cg_tot", n_cg_tot);
125 multi1d<Real>& lambda_H,
126 multi1d<LatticeFermion>&
psi,
134 const Real& gamma_factor,
140 const Real& zero_cutoff,
142 const bool ProjApsiP,
156 if( lambda_H.size() < (n_eig+n_dummy) ) {
157 QDP_error_exit(
"lambda_H is too small to hold n_eig + n_dummy values\n");
161 if(
psi.size() < (n_eig + n_dummy) ) {
162 QDP_error_exit(
"psi is too small to hold n_eig + n_dummy values\n");
174 Rsd_a, zero_cutoff, ProjApsiP, n_cg_tot, xml_out);
180 int n_working_eig = n_eig+n_dummy;
181 multi1d<Real> lambda_intern(n_working_eig);
182 multi1d<Real> lambda_previous(n_working_eig);
183 multi1d<Real> delta_cycle(n_working_eig);
185 for(
i = 0;
i < n_working_eig;
i++) {
186 lambda_intern[
i] = lambda_H[
i];
187 lambda_previous[
i] = Real(1);
188 delta_cycle[
i] = Real(1);
192 multi1d<Complex> off_diag((n_working_eig)*(n_working_eig-1)/2);
195 multi1d<Real> final_grad(n_working_eig);
205 push(xml_out,
"EigSpecRitzKS");
208 for(
int KS_iter = 0; KS_iter < n_max_KS; KS_iter++) {
211 push(xml_out,
"KS_iter");
216 for(ev = 1,
i=0; ev <= n_working_eig; ev++,
i++) {
219 Ritz(M, lambda_intern[
i],
psi, ev, Rsd_r, Rsd_a, zero_cutoff, n_renorm,
220 n_min, n_max,
MaxCG, ProjApsiP,
n_count, final_grad[
i],
true,
221 Real(1), gamma_factor);
227 write(xml_out,
"final_grad", final_grad[
i]);
239 for(
i=0, ij=0;
i < n_working_eig;
i++) {
241 for(
j=0;
j <
i;
j++) {
252 n_jacob =
SN_Jacob(
psi, n_working_eig, lambda_intern, off_diag, Rsd_a, 50,
s);
253 n_jacob_tot += n_jacob;
255 write(xml_out,
"n_jacob", n_jacob);
263 for(
i=0;
i < n_eig;
i++) {
264 bool zeroReachedP = toBool( fabs(lambda_intern[
i]) < zero_cutoff );
271 convP &= ( toBool( final_grad[
i] < Rsd_a )
272 || toBool( final_grad[
i] < Rsd_r*fabs(lambda_intern[
i]) )
283 for(
i=0, ij=0;
i < n_eig;
i++) {
285 for(
j=0;
j <
i;
j++) {
292 n_jacob =
SN_Jacob(
psi, n_eig, lambda_intern, off_diag, Rsd_a, 50,
s);
293 write(xml_out,
"final_n_jacob", n_jacob);
294 write(xml_out,
"n_cg_tot", n_cg_tot);
295 write(xml_out,
"n_KS", n_KS);
299 for(
i=0;
i < n_eig;
i++) {
300 lambda_H[
i] = lambda_intern[
i];
303 write(xml_out,
"lambda_H", lambda_H);
311 write(xml_out,
"n_cg_tot", n_cg_tot);
312 write(xml_out,
"n_KS", n_KS);
322 multi1d<Real>& lambda,
324 multi1d<LatticeFermion>& ev_psi,
328 const Real& zero_cutoff,
329 multi1d<bool>& valid_eig,
339 if( n_eig > lambda.size() ) {
343 if( lambda.size() != ev_psi.size() ) {
348 valid_eig.resize(n_eig);
359 Double lambda_fix_single = innerProductReal(ev_psi[0],
tmp);
364 lambda_H_sq = lambda_fix_single*lambda_fix_single;
369 if( toBool( lambda_H_sq < zero_cutoff ) ) {
375 if( toBool( lambda[0] < zero_cutoff ) ) {
382 valid_eig[0] =
false;
388 delta_lambda = fabs( lambda_H_sq -
Double( lambda[0] ) );
390 convP = toBool( delta_lambda <
Double(Rsd_a) )
391 || toBool( delta_lambda <
Double(Rsd_r)*fabs(
Double(lambda[0])) );
399 valid_eig[0] =
false;
406 lambda[0] = Real(lambda_fix_single);
413 multi1d<Complex> off_diag(n_eig*(n_eig-1)/2 );
414 multi1d<Real> lambda_fix(n_eig);
415 for(
int i = 0;
i < n_eig;
i++) {
416 valid_eig[
i] =
false;
419 for(
int i=0, ij=0;
i < n_eig;
i++) {
421 lambda_fix[
i] = innerProductReal(ev_psi[
i],
tmp);
423 for(
int j=0;
j <
i;
j++) {
430 n_jacob =
SN_Jacob(ev_psi, n_eig, lambda_fix, off_diag, Rsd_a, 50,
s);
435 for(
int i=0;
i < n_eig;
i++) {
440 if( toBool(lambda_H_sq < zero_cutoff ) ) {
443 for(
int j = n_valid; (
j < n_eig ) && ( valid_eig[
i] ==
false );
j++ ) {
447 if( toBool( lambda[
j] < zero_cutoff ) ) {
454 Real
tmp = lambda[
j];
455 lambda[
j] = lambda[n_valid];
456 lambda[n_valid] =
tmp;
471 for(
int j = n_valid; (
j < n_eig ) && ( valid_eig[
i] ==
false );
j++ ) {
472 delta_lambda = fabs( lambda_H_sq -
Double(lambda[
j]) );
474 convP = toBool( delta_lambda <
Double(Rsd_a) )
475 || toBool( delta_lambda <
Double(Rsd_r) * fabs(
Double(lambda[
j]) ) );
483 Real
tmp = lambda[
j];
484 lambda[
j] = lambda[n_valid];
485 lambda[n_valid] =
tmp;
502 for(
int i = 0;
i < n_eig;
i++ ) {
503 lambda[
i] = lambda_fix[
i];
Primary include file for CHROMA library code.
virtual const Subset & subset() const =0
Return the subset on which the operator acts.
int SN_Jacob(multi1d< LatticeFermion > &psi, const int N_eig, multi1d< Real > &lambda, multi1d< Complex > &off_diag, Real tolerance, int N_max, const Subset &sub)
Single-node Jacobi rotation.
void EigSpecRitzCG(const LinearOperator< LatticeFermion > &M, multi1d< Real > &lambda_H, multi1d< LatticeFermion > &psi, int n_eig, int n_renorm, int n_min, int MaxCG, const Real &Rsd_r, const Real &Rsd_a, const Real &zero_cutoff, const bool ProjApsiP, int &n_cg_tot, XMLWriter &xml_out)
Compute low lying eigenvalues of the hermitian H.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams ¶m)
Writer parameters.
BinaryReturn< C1, C2, FnInnerProduct >::Type_t innerProduct(const QDPSubType< T1, C1 > &s1, const QDPType< T2, C2 > &s2)
Asqtad Staggered-Dirac operator.
void fixMMev2Mev(const LinearOperator< LatticeFermion > &M, multi1d< Real > &lambda, multi1d< LatticeFermion > &ev_psi, const int n_eig, const Real &Rsd_r, const Real &Rsd_a, const Real &zero_cutoff, multi1d< bool > &valid_eig, int &n_valid, int &n_jacob)
void EigSpecRitzKS(const LinearOperator< LatticeFermion > &M, multi1d< Real > &lambda_H, multi1d< LatticeFermion > &psi, int n_eig, int n_dummy, int n_renorm, int n_min, int n_max, int n_max_KS, const Real &gamma_factor, int MaxCG, const Real &Rsd_r, const Real &Rsd_a, const Real &zero_cutoff, const bool ProjApsiP, int &n_cg_tot, int &n_KS, int &n_jacob_tot, XMLWriter &xml_out)
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
push(xml_out,"Condensates")
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > int MaxCG
void Ritz(const LinearOperator< LatticeFermion > &A, Real &lambda, multi1d< LatticeFermion > &psi_all, int N_eig, const Real &Rsd_r, const Real &Rsd_a, const Real &zero_cutoff, int n_renorm, int n_min, int n_max, int MaxCG, bool ProjApsiP, int &n_count, Real &final_grad, bool Kalk_Sim, const Real &delta_cycle, const Real &gamma_factor)
multi1d< LatticeFermion > s(Ncb)
FloatingPoint< double > Double