CHROMA
read_rat_approx.cc
Go to the documentation of this file.
1 #include "chromabase.h"
5 
6 namespace Chroma {
7 
8  namespace ReadRatApproxEnv
9  {
10  //! Callback function
11  RationalApprox* createApprox(XMLReader& xml_in,
12  const std::string& path)
13  {
14  return new ReadRatApprox(Params(xml_in, path));
15  }
16 
17 
18  //! Name to be used
19  const std::string name = "READ_COEFFS";
20 
21  //! Local registration flag
22  static bool registered = false;
23 
24  //! Register all the factories
25  bool registerAll()
26  {
27  bool success = true;
28  if (! registered)
29  {
30  success &= Chroma::TheRationalApproxFactory::Instance().registerObject(name, createApprox);
31  registered = true;
32  }
33  return success;
34  }
35 
36  //! Params for Remez type rational approximation
37  /*! @ingroup monomial */
38  Params::Params(XMLReader& in, const std::string& path) {
39 
40  try {
41  XMLReader paramtop(in,path);
42 
43 
44  XMLReader pfe_in(paramtop, "PFECoeffs");
45  read(pfe_in, "norm", pfe.norm);
46  read(pfe_in, "res", pfe.res);
47  read(pfe_in, "pole", pfe.pole);
48  XMLReader ipfe_in(paramtop, "IPFECoeffs");
49  read(ipfe_in, "norm", ipfe.norm);
50  read(ipfe_in, "res", ipfe.res);
51  read(ipfe_in, "pole", ipfe.pole);
52  }
53  catch(const std::string& e) {
54  QDPIO::cout << "Caught Exception reading XML" << e << std::endl;
55  QDP_abort(1);
56  }
57  }
58 
59  void Params::writeXML(XMLWriter& out, const std::string& path) const {
60  push(out, path);
61  push(out, "PFECoeffs");
62  write(out, "norm", pfe.norm);
63  write(out, "res", pfe.res);
64  write(out, "pole", pfe.pole);
65  pop(out);
66  push(out, "IPFECoeffs");
67  write(out, "norm", ipfe.norm);
68  write(out, "res", ipfe.res);
69  write(out, "pole", ipfe.pole);
70  pop(out);
71 
72  }
73 
74 
75 
76  } // Namespace
77 
78  void read(XMLReader &xml, const std::string& path, ReadRatApproxEnv::Params& param) {
79  ReadRatApproxEnv::Params tmp(xml, path);
80  param=tmp;
81  }
82 
83  //! Write Parameters
84  void write(XMLWriter& xml, const std::string& path, const ReadRatApproxEnv::Params& param)
85  {
86  param.writeXML(xml, path);
87  }
88 
89 
91  {
92  pfe=params.pfe;
93  ipfe=params.ipfe;
94  }
95 
96 }
Primary include file for CHROMA library code.
Base class for rational approximations.
Definition: rat_approx.h:19
Remez type of rational approximations.
ReadRatApproxEnv::Params params
void operator()(RemezCoeff_t &pfe, RemezCoeff_t &ipfe) const
Produce the partial-fraction-expansion (PFE) and its inverse (IPFE)
static T & Instance()
Definition: singleton.h:432
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
const std::string name
Name to be used.
static bool registered
Local registration flag.
RationalApprox * createApprox(XMLReader &xml_in, const std::string &path)
Callback function.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
pop(xml_out)
static QDP_ColorVector * out
Constructor.
static QDP_ColorVector * in
::std::string string
Definition: gtest.h:1979
Rational approximation aggregator.
Rational approximation factories.
Remez-type rational approximation.
Params for Remez type rational approximation.
void writeXML(XMLWriter &in, const std::string &path) const
Convenient structure to package Remez coeffs.
Definition: remez_coeff.h:19
multi1d< Real > pole
Definition: remez_coeff.h:21
multi1d< Real > res
Definition: remez_coeff.h:20