27 template<
typename TestType>
30 using T = LatticeFermion;
31 using Q = multi1d<LatticeColorMatrix>;
32 using P = multi1d<LatticeColorMatrix>;
50 XMLReader xml_in_asymm(input_asymm);
51 XMLReader xml_in_symm(input_symm);
57 XMLReader xml_in_asymm_periodic(input_asymm_periodic);
58 XMLReader xml_in_symm_periodic(input_symm_periodic);
59 XMLReader xml_in_twisted(twisted_fermact);
70 xml_in_asymm_periodic,
81 state = S_asymm->createState(
u);
110 LatticeFermion
x=
zero;
113 LatticeFermion t1 =
zero;
116 LatticeFermion AM_symm_x =
zero;
117 LatticeFermion M_asymm_x =
zero;
120 QDPIO::cout <<
"Op: " << std::endl;
122 (*M_symm)(t1,
x,
PLUS);
123 (*M_symm).unprecOddOddLinOp(AM_symm_x,t1,
PLUS);
126 (*M_asymm)(M_asymm_x,
x,
PLUS);
128 M_asymm_x -= AM_symm_x;
129 Double norm_cb0 = sqrt(norm2(M_asymm_x,rb[0]));
130 Double norm_cb1 = sqrt(norm2(M_asymm_x,rb[1]));
132 QDPIO::cout <<
"CB=0: || A_oo M_symm_x - M_asymm_x ||= " << norm_cb0 <<std::endl;
133 QDPIO::cout <<
"CB=1: || A_oo M_symm_x - M_asymm_x ||= " << norm_cb1
134 <<
" || A_oo M_symm_x - M_asymm_x ||/ ||x||=" << norm_cb1/sqrt(norm2(
x,rb[1]))
142 QDPIO::cout <<
"Daggered Op: " << std::endl;
143 (*M_symm).unprecOddOddLinOp(t1,
x,
MINUS);
144 (*M_symm)(AM_symm_x,t1,
MINUS);
146 (*M_asymm)(M_asymm_x,
x,
MINUS);
147 M_asymm_x -= AM_symm_x;
148 Double norm_cb0 = sqrt(norm2(M_asymm_x,rb[0]));
149 Double norm_cb1 = sqrt(norm2(M_asymm_x,rb[1]));
151 QDPIO::cout <<
"CB=0: || A_oo M_symm_x - M_asymm_x ||= " << norm_cb0 <<std::endl;
152 QDPIO::cout <<
"CB=1: || A_oo M_symm_x - M_asymm_x ||= " << norm_cb1
153 <<
" || A_oo M_symm_x - M_asymm_x ||/ ||x||=" << norm_cb1/sqrt(norm2(
x,rb[1]))
172 QDPIO::cout <<
"Regular Op:" << std::endl;
174 (*M_symm).unprecLinOp( unprec_symm_x,
x,
PLUS);
175 (*M_asymm).unprecLinOp( unprec_asymm_x,
x,
PLUS);
177 unprec_asymm_x -= unprec_symm_x;
178 Double norm_cb0 = sqrt(norm2(unprec_asymm_x,rb[0]));
179 Double norm_cb1 = sqrt(norm2(unprec_asymm_x,rb[1]));
181 QDPIO::cout <<
"CB=0: || Munprec_symm_x - Munprec_asymm_x ||= " << norm_cb0 <<std::endl;
182 QDPIO::cout <<
"CB=1: || Munprec_symm_x - Munprec_asymm_x ||= " << norm_cb1 << std::endl;
190 QDPIO::cout <<
"Daggered Op:" << std::endl;
192 (*M_symm).unprecLinOp( unprec_symm_x,
x,
MINUS);
193 (*M_asymm).unprecLinOp( unprec_asymm_x,
x,
MINUS);
194 unprec_asymm_x -= unprec_symm_x;
196 Double norm_cb0 = sqrt(norm2(unprec_asymm_x,rb[0]));
197 Double norm_cb1 = sqrt(norm2(unprec_asymm_x,rb[1]));
199 QDPIO::cout <<
"CB=0: || Munprec_symm_x - Munprec_asymm_x ||= " << norm_cb0 <<std::endl;
200 QDPIO::cout <<
"CB=1: || Munprec_symm_x - Munprec_asymm_x ||= " << norm_cb1 << std::endl;
212 LatticeFermion rhs=
zero;
215 std::istringstream inv_param_xml_stream(GetParam());
216 XMLReader xml_in(inv_param_xml_stream);
220 LatticeFermion
x =
zero;
222 (*qprop_solver)(
x,rhs);
225 LatticeFermion Ax=
zero;
226 (*M_symm).unprecLinOp(Ax,
x,
PLUS);
229 Double resid_cb0 = sqrt(norm2(Ax,rb[0]));
230 Double resid_cb1 = sqrt(norm2(Ax,rb[1]));
231 QDPIO::cout <<
"Qprop: rsd cb0 = " << resid_cb0 << std::endl;
232 QDPIO::cout <<
"Qprop: rsd cb1 = " << resid_cb1 << std::endl;
234 Double resid = sqrt(norm2(Ax));
235 Double resid_rel = resid/sqrt(norm2(rhs));
236 QDPIO::cout <<
"QProp Check Back: || r || = " << resid <<
" || r ||/||b|| = "
237 << resid_rel << std::endl;
251 inv_param_quda_multigrid_xml));
260 std::istringstream inv_param_xml_stream(GetParam());
261 XMLReader xml_in(inv_param_xml_stream);
269 (*MdagM_solver)(
x,
b);
277 Double resid = sqrt(norm2(
r,rb[1]));
278 Double resid_rel = resid/sqrt(norm2(
b,rb[1]));
279 QDPIO::cout <<
"MdagM check: || r || = " << resid <<
" || r || / || b ||=" << resid_rel << std::endl;
289 std::istringstream inv_param_xml_stream(GetParam());
290 XMLReader xml_in(inv_param_xml_stream);
298 (*MdagM_solver)(
x,
b,chrono);
306 Double resid = sqrt(norm2(
r,rb[1]));
307 Double resid_rel = resid/sqrt(norm2(
b,rb[1]));
308 QDPIO::cout <<
"MdagM check: || r || = " << resid <<
" || r || / || b ||=" << resid_rel << std::endl;
318 std::istringstream inv_param_xml_stream(GetParam());
319 XMLReader xml_in(inv_param_xml_stream);
327 (*MdagM_solver)(
x,
b);
335 Double resid = sqrt(norm2(
r,rb[1]));
336 Double resid_rel = resid/sqrt(norm2(
b,rb[1]));
337 QDPIO::cout <<
"MdagM check: || r || = " << resid <<
" || r || / || b ||=" << resid_rel << std::endl;
347 std::istringstream inv_param_xml_stream(GetParam());
348 XMLReader xml_in(inv_param_xml_stream);
358 (*MdagM_solver)(
x,
b,chrono);
366 Double resid = sqrt(norm2(
r,rb[1]));
367 Double resid_rel = resid/sqrt(norm2(
b,rb[1]));
368 QDPIO::cout <<
"MdagM check: || r || = " << resid <<
" || r || / || b ||=" << resid_rel << std::endl;
382 inv_param_quda_multigrid_xml));
393 inv_param_quda_multigrid_asymm_xml));
401 std::istringstream inv_param_xml_stream(GetParam());
402 XMLReader xml_in(inv_param_xml_stream);
412 multi1d<Real> shifts(n_shift);
418 multi1d<T> solns(n_shift);
419 for(
int shift=0; shift < n_shift; ++shift) {
420 (solns[shift])[rb[1]]=
zero;
424 (*multiMdagM)(solns,shifts,rhs);
426 for(
int shift = 0; shift < n_shift; ++shift) {
430 (*M_symm)(
tmp,solns[shift],
PLUS);
435 r[rb[1]] += shifts[shift]*solns[shift];
440 Double resid_rel = sqrt(norm2(
r,rb[1])/norm2(rhs,rb[1]));
441 QDPIO::cout <<
"shift="<<shift <<
" || r || / || b ||=" << resid_rel << std::endl;
448 std::istringstream inv_param_xml_stream(GetParam());
449 XMLReader xml_in(inv_param_xml_stream);
459 multi1d<Real> shifts(n_shift);
465 multi1d<T> solns(n_shift);
466 for(
int shift=0; shift < n_shift; ++shift) {
467 (solns[shift])[rb[1]]=
zero;
471 (*multiMdagM)(solns,shifts,rhs);
473 for(
int shift = 0; shift < n_shift; ++shift) {
477 (*M_asymm)(
tmp,solns[shift],
PLUS);
482 r[rb[1]] += shifts[shift]*solns[shift];
487 Double resid_rel = sqrt(norm2(
r,rb[1])/norm2(rhs,rb[1]));
488 QDPIO::cout <<
"shift="<<shift <<
" || r || / || b ||=" << resid_rel << std::endl;
548 (*M_symm).unprecOddOddInvLinOp(W,
tmp,
PLUS);
550 (*M_symm).unprecOddOddInvLinOp(Z,X,
MINUS);
553 (*M_symm).deriv(ds_symm,X,Y,
PLUS);
556 (*M_asymm).deriv(rhs,Z,Y,
PLUS);
559 (*M_symm).derivUnprecOddOddLinOp(ds_tmp,Z,W,
PLUS);
563 rhs[
mu] -= ds_symm[
mu];
564 Double norm_rhs = sqrt(norm2(rhs[
mu]));
565 Double norm_rhs_per_number = norm_rhs/
Double(3*3*2*Layout::vol());
566 QDPIO::cout <<
"mu=" <<
mu <<
" || rhs - ds_symm || = " << norm_rhs
567 <<
" || rhs - ds_symm || / number =" << norm_rhs_per_number << std::endl;
569 ASSERT_LT(toDouble(norm_rhs_per_number), 1.0e-18 );
606 (*M_symm).unprecOddOddInvLinOp(W,Y,
MINUS);
610 (*M_symm).unprecOddOddInvLinOp(Z,
tmp,
PLUS);
613 (*M_symm).deriv(ds_symm,X,Y,
MINUS);
616 (*M_asymm).deriv(rhs,X,W,
MINUS);
619 (*M_symm).derivUnprecOddOddLinOp(ds_tmp,Z,W,
MINUS);
623 rhs[
mu] -= ds_symm[
mu];
624 Double norm_rhs = sqrt(norm2(rhs[
mu]));
625 Double norm_rhs_per_number = norm_rhs/
Double(3*3*2*Layout::vol());
626 QDPIO::cout <<
"mu=" <<
mu <<
" || rhs - ds_symm || = " << norm_rhs
627 <<
" || rhs - ds_symm || / number =" << norm_rhs_per_number << std::endl;
629 ASSERT_LT(toDouble(norm_rhs_per_number), 1.0e-18 );
642 QDPIO::cout <<
"Unit Gauge Symm Linop creation" << std::endl;
645 Double S_e = lop->logDetEvenEvenLinOp();
646 Double S_o = lop->logDetOddOddLinOp();
647 QDPIO::cout <<
"Unit gauge: log Det EvenEven = " << S_e << std::endl;
648 QDPIO::cout <<
"Unit gauge: log Det OddOdd = " << S_o << std::endl;
650 Double absdiff = fabs(S_e-S_o);
651 QDPIO::cout <<
"Unit gauge: | S_e - S_o | = " << absdiff << std::endl;
658 u_shifted.resize(
Nd);
665 QDPIO::cout <<
"Shifted Gauge Symm Linop creation" << std::endl;
667 Handle<LinOpSymm_T> shifted_lop =
dynamic_cast<LinOpSymm_T*
>(S_symm->linOp(shifted_state));
669 Double S_e_asymm = M_asymm->logDetEvenEvenLinOp();
670 Double S_e = M_symm->logDetEvenEvenLinOp();
671 Double S_o = M_symm->logDetOddOddLinOp();
673 Double S_e_shifted = shifted_lop->logDetEvenEvenLinOp();
674 Double S_o_shifted = shifted_lop->logDetOddOddLinOp();
676 QDPIO::cout <<
"Asymm op log Det EvenEven = " << S_e_asymm << std::endl;
677 QDPIO::cout <<
"Random gauge: log Det EvenEven = " << S_e << std::endl;
678 QDPIO::cout <<
"Random gauge: log Det OddOdd = " << S_o << std::endl;
679 QDPIO::cout <<
"Shifted gauge: log Det EvenEven = " << S_e_shifted << std::endl;
680 QDPIO::cout <<
"Shifted gauge: log Det OddOdd = " << S_o_shifted << std::endl;
682 Double diff_e_symm_asymm = fabs(S_e_asymm - S_e);
683 Double diff_eo = fabs(S_e - S_o_shifted)/
Double(rb[0].numSiteTable());
684 Double diff_oe = fabs(S_o - S_e_shifted)/
Double(rb[1].numSiteTable());
685 QDPIO::cout <<
"| logDet_e_asymm - logdet_e_symm | = " << diff_e_symm_asymm << std::endl;
686 QDPIO::cout <<
"| logDet_e - logDet_o_shifted |/site = " << diff_eo << std::endl;
687 QDPIO::cout <<
"| logDet_o - logDet_e_shifted |/site = " << diff_oe << std::endl;
689 ASSERT_LT( toDouble(diff_e_symm_asymm), 1.0e-14);
698 Real twist=Real(0.05);
703 LatticeFermion source;
705 LatticeFermion t1, t2;
708 (*M_tw)(t1,source,
PLUS);
709 (*M_symm)(t2,source,
PLUS);
710 t2[ rb[1] ] += twist*(GammaConst<Ns,Ns*Ns-1>()*timesI(source));
713 Double normdiff = sqrt(norm2(t2,rb[1]));
714 QDPIO::cout <<
"PLUS : || M(mu) - ( Mdag + i gamma_5 mu ) || = "
715 << normdiff << std::endl;
721 (*M_tw)(t1,source,
MINUS);
722 (*M_symm)(t2,source,
MINUS);
723 t2[ rb[1] ] -= twist*(GammaConst<Ns,Ns*Ns-1>()*timesI(source));
726 Double normdiff = sqrt(norm2(t2,rb[1]));
727 QDPIO::cout <<
"MINUS : || M^dag(mu) - ( Mdag - igamma5 mu ) || = " << normdiff << std::endl;
733 LatticeFermion mdagm,t3;
734 (*M_tw)(t1,source,
PLUS);
735 (*M_tw)(t2,t1,
MINUS);
738 (*M_symm)(t1,source,
PLUS);
739 (*M_symm)(mdagm,t1,
MINUS);
742 mdagm[rb[1]] += (twist*twist)*source;
745 t1[rb[1]] = (GammaConst<Ns,Ns*Ns-1>()*timesI(source));
746 (*M_symm)(t3,t1,
MINUS);
747 mdagm[rb[1]] += twist*t3;
750 (*M_symm)(t1,source,
PLUS);
751 t3[rb[1]] = (GammaConst<Ns,Ns*Ns-1>()*timesI(t1));
752 mdagm[rb[1]] -= twist*t3;
756 Double normdiff = sqrt(norm2(mdagm,rb[1]));
757 QDPIO::cout <<
"MDAGM : || M^dag(mu)M(mu) - ( Mdag M + mu^2 + imu[ M^dag g_5 - g_5 M ]) || = " << normdiff << std::endl;
766 u_shifted.resize(
Nd);
774 QDPIO::cout <<
"Shifted Gauge Symm Linop creation" << std::endl;
776 Handle<LinOpAsymm_T> asymm_periodic_op =
dynamic_cast<LinOpAsymm_T*
>(S_asymm_periodic->linOp(periodic_state));
777 Handle<LinOpSymm_T> symm_periodic_op =
dynamic_cast<LinOpSymm_T*
>(S_symm_periodic->linOp(periodic_state));
778 Handle<LinOpSymm_T> shifted_periodic_op =
dynamic_cast<LinOpSymm_T*
>(S_symm_periodic->linOp(periodic_shifted_state));
783 asymm_periodic_op->derivLogDetEvenEvenLinOp(ds_asymm,GetParam());
786 symm_periodic_op->derivLogDetEvenEvenLinOp(ds_symm,GetParam());
789 shifted_periodic_op->derivLogDetOddOddLinOp(ds_symm_shifted, GetParam());
791 P ds_unshifted; ds_unshifted.resize(
Nd);
792 P ds_wrong_shifted; ds_wrong_shifted.resize(
Nd);
794 ds_unshifted[
mu] = shift(ds_symm_shifted[
mu],
BACKWARD,3);
795 ds_wrong_shifted[
mu] = shift(ds_symm_shifted[
mu],
FORWARD, 3);
798 Double mu_contrib_asymm = norm2(ds_asymm[
mu]);
800 Double mu_contrib_symm = norm2(ds_symm[
mu]);
802 Double mu_contrib_shifted = norm2(ds_symm_shifted[
mu]);
804 QDPIO::cout <<
"mu=" <<
mu <<
" asymm force norm="<< mu_contrib_asymm << std::endl;
805 QDPIO::cout <<
"mu=" <<
mu <<
" symm force norm ="<< mu_contrib_symm << std::endl;
806 QDPIO::cout <<
"mu=" <<
mu <<
" shifted force norm="<< mu_contrib_shifted << std::endl;
809 Double diff_symm_asymm_ee = fabs(mu_contrib_asymm - mu_contrib_symm );
810 Double diff_symm_ee_oo = fabs(mu_contrib_symm - mu_contrib_shifted );
812 QDPIO::cout <<
"mu=" <<
mu <<
" | F_asymm_ee - F_symm_ee | = " << diff_symm_asymm_ee << std::endl;
813 QDPIO::cout <<
"mu=" <<
mu <<
" | F_ee - F_shifted_oo | = " << diff_symm_ee_oo << std::endl;
815 ASSERT_LT( toDouble(diff_symm_asymm_ee), 1.0e-15);
816 ASSERT_LT( toDouble(diff_symm_ee_oo), 1.0e-15);
818 ds_unshifted[
mu] -= ds_symm[
mu];
819 ds_wrong_shifted[
mu] -= ds_symm[
mu];
820 Double diffnorm_unshifted = sqrt(norm2(ds_unshifted[
mu]));
821 Double diffnorm_per_site = diffnorm_unshifted/Layout::vol();
822 QDPIO::cout <<
"mu=" <<
mu <<
" || F_mu - shift(F_shifted, BACKWARD, mu) || =" << diffnorm_unshifted << std::endl;
823 QDPIO::cout <<
"mu=" <<
mu <<
" || F_mu - shift(F_shifted, BACKWARD, mu) ||/site =" << diffnorm_per_site << std::endl;
825 ASSERT_LT( toDouble(diffnorm_per_site), 1.0e-14 );
827 Double diffnorm_wrong_shifted = sqrt(norm2(ds_wrong_shifted[
mu]));
828 QDPIO::cout <<
"mu=" <<
mu <<
" DELIBERATELY WRONG: || F_mu - shift(F_shifted, FORWARD, mu) || =" << diffnorm_wrong_shifted << std::endl;
829 ASSERT_GT( toDouble(diffnorm_wrong_shifted), 0.5);
830 QDPIO::cout << std::endl;
843 multi1d<T> X(n_poles);
844 multi1d<T> Y(n_poles);
847 for(
int i=0;
i < n_poles; ++
i) {
852 multi1d<LatticeColorMatrix> ds_u(
Nd);
853 multi1d<LatticeColorMatrix> ds_tmp(
Nd);
854 multi1d<LatticeColorMatrix> ds_mp(
Nd);
856 for(
int dag=0; dag < 2; ++dag ) {
857 QDPIO::cout <<
"Dagger = " << dag << std::endl;
869 for(
int i=0;
i < n_poles; ++
i) {
870 M_symm->deriv(ds_tmp, X[
i],Y[
i],
isign);
874 QDPIO::cout <<
"Individual Poles took: " << swatch.getTimeInSeconds() <<
" sec." << std::endl;
877 swatch.reset(); swatch.start();
878 M_symm->derivMultipole(ds_mp, X,Y,
isign);
880 QDPIO::cout <<
"Multipole took: " << swatch.getTimeInSeconds() <<
" sec." << std::endl;
883 ds_mp[
mu] -= ds_u[
mu];
884 Double normdiff = sqrt(norm2(ds_mp[
mu]));
885 Double normdiff_per_link = normdiff/
static_cast<double>(4*Layout::vol());
886 QDPIO::cout <<
"mu="<<
mu <<
" normdiff = " << normdiff
887 <<
" normdiff per link = " << normdiff_per_link << std::endl;
888 ASSERT_LT( toDouble(normdiff_per_link), 1.0e-17);
Primary include file for CHROMA library code.
Even-odd preconditioned Clover-Dirac operator.
Even-odd preconditioned Wilson-like fermion actions including derivatives.
Zero initial guess predictor.
Symmetric even-odd preconditioned Clover-Dirac operator.
Symmetric even-odd preconditioned Wilson-like fermion actions including derivatives.
Handle< S_symm_T > S_symm_periodic
Handle< LinOpSymm_T > M_symm
Handle< FermState< T, P, Q > > state
Handle< S_asymm_T > S_asymm
Handle< S_asymm_T > S_asymm_periodic
Handle< LinOpSymm_T > M_tw
multi1d< LatticeColorMatrix > Q
Handle< LinOpAsymm_T > M_asymm
Handle< S_symm_T > S_symm
Handle< S_symm_T > S_symm_twisted
multi1d< LatticeColorMatrix > P
Even-odd preconditioned Clover fermion linear operator.
Base class for even-odd preconditioned 4D and 5D Linop.
Even-odd preconditioned Wilson-like fermion actions.
Fermion action factories.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
#define ASSERT_GT(val1, val2)
#define ASSERT_LT(val1, val2)
Class for counted reference semantics.
Asqtad Staggered-Dirac operator.
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::Q Q
LinOpSysSolverMGProtoClover::T T
void reunit(LatticeColorMatrixF3 &xa)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
std::string fermact_xml_symm
std::string inv_param_multi_cg_xml
std::string fermact_xml_asymm_periodic
std::string fermact_xml_asymm
std::string inv_param_syssolver_bicgstab_xml
std::string fermact_xml_symm_periodic
std::string fermact_xml_symm_twisted
FloatingPoint< double > Double
internal::ValueArray1< T1 > Values(T1 v1)
Pick channel for QUDA Predictor.
Reunitarize in place a color matrix to SU(N)
Symmetric even-odd preconditioned Clover fermion linear operator.
Base class for symmetric even-odd preconditioned 4D and 5D Linop.
Symmetric even-odd preconditioned Wilson-like fermion actions.
Hold group xml and type id.
TEST_P(QPropTest, CheckQprop)
TEST_F(SymmFixture, CheckOp)
INSTANTIATE_TEST_CASE_P(PropSyssolver, QPropTest, ::testing::Values(inv_param_syssolver_bicgstab_xml))
multi1d< LatticeColorMatrix > P
Read an XML group as a std::string.