20 #include <qdp-lapack.h>
26 namespace InlineLaplaceEigsEnv
32 XMLReader inputtop(xml, path);
56 XMLReader inputtop(xml, path);
61 read(inputtop,
"tol", input.
tol);
70 write(xml,
"num_vecs",
out.num_vecs);
71 write(xml,
"decay_dir",
out.decay_dir);
72 write(xml,
"max_iter",
out.max_iter);
74 xml <<
out.link_smear.xml;
100 namespace InlineLaplaceEigsEnv
107 return new InlineMeas(Params(xml_in, path));
138 XMLReader paramtop(xml_in, path);
140 if (paramtop.count(
"Frequency") == 1)
152 if (paramtop.count(
"xml_file") != 0)
159 QDPIO::cerr << __func__ <<
": Caught Exception reading XML: " << e << std::endl;
176 push(xml_out,
"LaplaceEigs");
177 write(xml_out,
"update_no", update_no);
178 write(xml_out,
"xml_file", xml_file);
181 XMLFileWriter xml(xml_file);
182 func(update_no, xml);
186 func(update_no, xml_out);
200 Real minus_one = -1.;
201 temp =
psi * minus_one;
206 void q(
const multi1d<LatticeColorMatrix>&
u,
207 const LatticeColorVector&
psi,
208 LatticeColorVector&
chi,
212 chi *= Real(-2.0 / 14.0);
213 chi +=
psi * Real(-1.0 - 2.0 * .35 / 14.0);
218 const LatticeColorVector&
psi,
219 LatticeColorVector&
chi,
223 double chebCo[6] = {-72.0, 840.0, -3584.0, 6912.0, -6144.0, 2048.0};
224 LatticeColorVector
tmp =
psi;
225 LatticeColorVector prev;
226 LatticeColorVector
final =
zero;
228 for(
int i = 2;
i <=
n;
i += 2){
237 final += chebCo[
i/2-1]*
chi;
257 multi1d<LatticeColorMatrix>
u;
258 XMLBufferWriter gauge_xml;
264 catch( std::bad_cast ) {
265 QDPIO::cerr <<
name <<
": caught dynamic cast error" << std::endl;
269 QDPIO::cerr <<
name <<
": std::map call failed: " << e << std::endl;
273 push(xml_out,
"LaplaceEigs");
274 write(xml_out,
"update_no", update_no);
276 QDPIO::cout <<
name <<
": Use the IRL method to solve for laplace eigenpairs" << std::endl;
284 write(xml_out,
"Config_info", gauge_xml);
286 push(xml_out,
"Output_version");
287 write(xml_out,
"out_version", 1);
291 MesPlq(xml_out,
"Observables",
u);
296 multi1d<LatticeColorMatrix> u_smr =
u;
300 XMLReader linktop(xml_l);
301 QDPIO::cout <<
"Link smearing type = "
308 (*linkSmearing)(u_smr);
311 QDPIO::cerr <<
name <<
": Caught Exception link smearing: "<<e<< std::endl;
316 MesPlq(xml_out,
"Smeared_Observables", u_smr);
327 XMLBufferWriter file_xml;
329 push(file_xml,
"MODMetaData");
331 write(file_xml,
"lattSize", QDP::Layout::lattSize());
333 write(file_xml,
"Config_info", gauge_xml);
336 file_str = file_xml.str();
341 XMLReader MapObjReader(xml_s);
351 catch (std::bad_cast) {
352 QDPIO::cerr <<
name <<
": caught dynamic cast error" << std::endl;
357 QDPIO::cerr <<
name <<
": error creating prop: " << e << std::endl;
363 QDP::MapObject<int,EVPair<LatticeColorVector> >& color_vecs =
379 multi1d<EVPair<LatticeColorVector> > ev_pairs(num_vecs);
380 for(
int n=0;
n < num_vecs; ++
n) {
381 ev_pairs[
n].eigenValue.weights.resize(nt);
388 LatticeColorVector starting_vectors;
405 multi1d<DComplex> vector_norms;
408 QDPIO::cout <<
"Normalizing starting std::vector" << std::endl;
415 QDPIO::cout <<
"Nt = " << nt << std::endl;
417 for(
int t=0;
t<nt; ++
t) {
420 vector_norms[
t] = Complex(sqrt(Real(real(vector_norms[
t]))));
421 starting_vectors[phases.
getSet()[
t]] /= vector_norms[
t];
429 QDPIO::cout <<
"Krylov Dim = " << kdim << std::endl;
432 multi1d< multi1d<DComplex> >
beta(kdim-1);
433 multi1d< multi1d<DComplex> >
alpha(kdim);
435 multi1d<double*>
d(nt);
436 multi1d<double*> e(nt);
437 multi1d<double*>
z(nt);
439 for (
int t = 0 ;
t < nt ; ++
t) {
440 d[
t] =
new double[kdim];
441 e[
t] =
new double[kdim - 1];
442 z[
t] =
new double[(kdim) * (kdim)];
445 for (
int k = 0 ;
k < kdim ; ++
k) {
456 multi1d<LatticeColorVector> lanczos_vectors(kdim);
457 lanczos_vectors[0] = starting_vectors;
463 for(
int k=0;
k<kdim-1; ++
k) {
469 LatticeColorVector temporary;
475 for(
int t=0;
t<nt; ++
t){
476 temporary[phases.
getSet()[
t]] -=
beta[
k-1][
t]*lanczos_vectors[
k-1];
482 for(
int t=0;
t<nt; ++
t){
488 QDPIO::cout <<
"Reorthogonalizing" << std::endl;
489 multi1d<DComplex> alpha_temp(nt);
494 for(
int t=0;
t<nt; ++
t){
495 temporary[phases.
getSet()[
t]] -= alpha_temp[
t]*lanczos_vectors[
k-1];
501 for(
int t=0;
t<nt; ++
t){
502 temporary[phases.
getSet()[
t]] -= alpha_temp[
t]*lanczos_vectors[
k];
512 for(
int t=0;
t<nt; ++
t) {
520 e[
t][
k] = toDouble(Real(real(
beta[
k][
t])));
538 LatticeColorVector
tmp;
542 for(
int t = 0;
t < nt;
t++){
604 double* work =
new double[2*(kdim) - 2];
610 multi1d< multi1d< multi1d<double> > > evecs(nt);
611 multi1d< multi1d<double> > evals(nt);
613 for(
int t = 0;
t < nt;
t++) {
619 QDPLapack::dsteqr(&compz, &ldz,
d[
t], e[
t],
z[
t], &ldz, work, &
info);
623 QDPIO::cout <<
"LAPACK routine completed: " << fossil.getTimeInSeconds() <<
" sec" << std::endl;
625 QDPIO::cout <<
"info = " <<
info << std::endl;
628 evecs[
t].resize(kdim);
629 evals[
t].resize(kdim);
631 for (
int v = 0 ; v < kdim ; ++v) {
632 evals[
t][v] =
d[
t][v];
636 evecs[
t][v].resize(kdim);
638 for (
int n = 0 ;
n < kdim ; ++
n) {
639 evecs[
t][v][
n] =
z[
t][v * (kdim ) +
n ];
643 multi1d<double> Av(kdim );
647 for (
int n = 0 ;
n < kdim ; ++
n) {
650 Av[
n] += toDouble(Real(real(
beta[
n-1][
t]))) *
654 if (
n != (kdim - 1)) {
656 Av[
n] += toDouble(Real(real(
beta[
n][
t]))) *
660 Av[
n] += toDouble(Real(real(
alpha[
n][
t]))) *
664 dcnt += (Av[
n] - evals[
t][v]*evecs[
t][v][
n]) *
665 (Av[
n] - evals[
t][v]*evecs[
t][v][
n]);
677 QDPIO::cout <<
"Obtaining eigenvectors of the laplacian" << std::endl;
679 LatticeColorVector vec_k =
zero;
683 for (
int t = 0 ;
t < nt ; ++
t) {
686 for (
int n = 0 ;
n < kdim ; ++
n) {
688 Real(evecs[
t][kdim - 1 -
k][
n]) * lanczos_vectors[
n];
701 ev_pairs[
k].eigenVector = vec_k;
726 multi1d< DComplex > temp(nt);
727 multi1d< DComplex > temp2(nt);
729 LatticeColorVector bvec =
zero;
735 for(
int t = 0;
t < nt;
t++){
736 Complex temp3 = temp[
t] / temp2[
t];
738 evals[
t][
k] = -1.0 * toDouble(Real(real(temp3)));
740 ev_pairs[
k].eigenValue.weights[
t] =
743 QDPIO::cout <<
"t = " <<
t << std::endl;
744 QDPIO::cout <<
"lap_evals[" <<
k <<
"] = " << evals[
t][
k] << std::endl;
747 LatticeColorVector lambda_v2 =
zero;
749 for(
int t = 0;
t < nt;
t++){
751 lambda_v2[phases.
getSet()[
t]] = Real(evals[
t][
k]) * vec_k;
755 multi1d< DComplex > dcnt_arr2(nt);
757 LatticeColorVector diffs2 = bvec + lambda_v2;
761 QDPIO::cout <<
"Testing Laplace Eigenvalue " <<
k << std::endl;
762 for(
int t = 0;
t < nt;
t++){
763 if(toDouble(Real(real(dcnt_arr2[
t]))) > 1e-5)
764 QDPIO::cout <<
"dcnt[" <<
k <<
"] = " << dcnt_arr2[
t] << std::endl;
769 for(
int n=0;
n < num_vecs;
n++) {
770 color_vecs.insert(
n, ev_pairs[
n]);
777 QDPIO::cout <<
name <<
": time for colorvec construction = "
778 << swatch.getTimeInSeconds()
779 <<
" secs" << std::endl;
787 XMLBufferWriter file_xml;
789 push(file_xml,
"LaplaceEigInfo");
790 write(file_xml,
"num_vecs", num_vecs);
792 write(file_xml,
"Config_info", gauge_xml);
795 XMLBufferWriter record_xml;
796 push(record_xml,
"SubsetVectors");
797 for(
int i(0);
i<num_vecs;
i++){
798 push(record_xml,
"EigenPair");
799 write(record_xml,
"EigenPairNumber",
i);
800 write(record_xml,
"EigenValues", ev_pairs[
i].eigenValue.weights);
812 QDPIO::cout <<
name <<
": total time = "
813 << snoop.getTimeInSeconds()
814 <<
" secs" << std::endl;
816 QDPIO::cout <<
name <<
": ran successfully" << std::endl;
Inline measurement factory.
Class for counted reference semantics.
void func(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
Fourier transform phase factor support.
int numSubsets() const
Number of subsets - length in decay direction.
const Set & getSet() const
The set to be used in sumMulti.
Class structure for fermion actions.
Gaussian smearing of color std::vector.
void klein_gord(const multi1d< LatticeColorMatrix > &u, const T &psi, T &chi, const Real &mass_sq, int j_decay)
Compute the covariant Klein-Gordon operator.
void proginfo(XMLWriter &xml)
Print out basic information about this program.
std::string makeXMLFileName(std::string xml_file, unsigned long update_no)
Return a xml file name for inline measurements.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
Use the Implicitly Restarted Lanczos method with a Tchebyshev polynomial preconditioner to solve for ...
All link smearing constructors.
Factory for producing link smearing objects.
Named object function std::map.
static bool registered
Local registration flag.
void q(const multi1d< LatticeColorMatrix > &u, const LatticeColorVector &psi, LatticeColorVector &chi, int j_decay)
void chebyshev(const multi1d< LatticeColorMatrix > &u, const LatticeColorVector &psi, LatticeColorVector &chi, int j_decay)
void write(XMLWriter &xml, const std::string &path, const Params::NamedObject_t &input)
Propagator output.
bool registerAll()
Register all the factories.
void partitionedInnerProduct(const T &phi, const T &chi, multi1d< DComplex > &inner_prod, const Set &product_set)
void read(XMLReader &xml, const std::string &path, Params::NamedObject_t &input)
Propagator input.
void laplacian(const multi1d< LatticeColorMatrix > &u, const T &psi, T &chi, int j_decay)
QDPSubTypeTrait< typename BinaryReturn< C1, C2, FnLocalInnerProduct >::Type_t >::Type_t localInnerProduct(const QDPSubType< T1, C1 > &l, const QDPType< T2, C2 > &r)
bool registerAll()
aggregate everything
static const LatticeInteger & beta(const int dim)
static const LatticeInteger & alpha(const int dim)
Asqtad Staggered-Dirac operator.
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
LinOpSysSolverMGProtoClover::T T
multi1d< LatticeFermion > chi(Ncb)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
static QDP_ColorVector * out
Constructor.
Print out basic info about this program.
Fourier transform phase factor support.
Holds of vectors and weights.