CHROMA
overlap_state_info.cc
Go to the documentation of this file.
1 
2 #include "chromabase.h"
3 #include "overlap_state_info.h"
4 
5 namespace Chroma {
6 
8 {
9  initedP = false;
10  ApproxMin = 0;
11  ApproxMax = 0;
12  NWilsVec = 0;
13  load_eigenP = false;
14 
15 
17  eigen_io.eigen_volfmt = QDPIO_SINGLEFILE;
18 
19  ritzery.Neig = 0;
20  ritzery.RsdR = 0;
21  ritzery.RsdA = 0;
22  ritzery.RsdZero = 0;
23  ritzery.ProjApsiP = false;
24  ritzery.Ndummy = 0;
25  ritzery.GammaFactor = 0;
26  ritzery.MaxKS =0;
27  ritzery.MinKSIter =0;
28  ritzery.MaxKSIter =0;
29  ritzery.MaxCG = 0;
30  ritzery.Nrenorm = 0;
31 
32 }
33 
34 void read(XMLReader& xml_in, const std::string& path, OverlapStateInfo& info)
35 {
36  bool initedP;
37  Real ApproxMin;
38  Real ApproxMax;
39  int NWilsVec;
40  bool load_eigenP;
41  EigenIO_t eigen_io;
42  RitzParams_t ritzery;
43 
44  initedP = false;
45  ApproxMin = 0;
46  ApproxMax = 0;
47  NWilsVec = 0;
48  load_eigenP = false;
49 
50  eigen_io.eigen_file="";
51  eigen_io.eigen_volfmt = QDPIO_SINGLEFILE;
52 
53  ritzery.Neig = 0;
54  ritzery.RsdR = 0;
55  ritzery.RsdA = 0;
56  ritzery.RsdZero = 0;
57  ritzery.ProjApsiP = false;
58  ritzery.Ndummy = 0;
59  ritzery.GammaFactor = 0;
60  ritzery.MaxKS =0;
61  ritzery.MinKSIter =0;
62  ritzery.MaxKSIter =0;
63  ritzery.MaxCG = 0;
64  ritzery.Nrenorm = 0;
65 
66  XMLReader reader(xml_in, path);
67  try
68  {
69  if( reader.count("NWilsVec") != 0 )
70  read(reader, "NWilsVec", NWilsVec);
71  }
72  catch(const std::string& e) {
73  QDPIO::cerr << "Caught exception : " << e << std::endl;
74  QDP_abort(1);
75  }
76 
77 
78  if( NWilsVec == 0 )
79  {
80  // No eigenbeasties
81  eigen_io.eigen_file="";
82  eigen_io.eigen_volfmt = QDPIO_SINGLEFILE;
83 
84  // Try reading approx min and optional approx max
85  // if approx max is not specified set it to 2*Nd
86  try {
87  if( reader.count("ApproxMin") == 0 )
88  ApproxMin = 0.0;
89  else
90  read(reader, "ApproxMin", ApproxMin);
91 
92  if( reader.count("ApproxMax") == 0 )
93  ApproxMax = 2*Nd;
94  else
95  read(reader, "ApproxMax", ApproxMax);
96  }
97  catch( const std::string& e) {
98  QDPIO::cerr << "Caught exception : " << e << std::endl;
99  }
100  }
101  else {
102  // We have eigenbeasties
103  ApproxMin =0;
104  ApproxMax =0;
105 
106  if( reader.count("Eig") == 1 ) {
107  if( reader.count("Ritz") == 1 ) {
108  QDPIO::cerr << "Cannot specify both Eig and Ritz " << std::endl;
109  QDP_abort(1);
110  }
111 
112 
113  // Read in the eigenstd::vector IO params
114  try {
115  read(reader, "Eig", eigen_io);
116  }
117  catch( const std::string& e ) {
118  QDPIO::cerr << "Caught exception: " << e << std::endl;
119  }
120  load_eigenP = true;
121 
122  }
123  else if ( reader.count("Ritz") == 1 ) {
124  if( reader.count("Eig") == 1 ) {
125  QDPIO::cerr << "Cannot specify both Eig and Ritz " << std::endl;
126  QDP_abort(1);
127  }
128 
129  try {
130  XMLReader ritzreader(reader, "Ritz");
131 
132  read(ritzreader, "RsdR", ritzery.RsdR);
133  read(ritzreader, "RsdA", ritzery.RsdA);
134  read(ritzreader, "RsdZero", ritzery.RsdZero);
135  read(ritzreader, "ProjApsiP", ritzery.ProjApsiP);
136  read(ritzreader, "Ndummy", ritzery.Ndummy);
137  read(ritzreader, "GammaFactor", ritzery.GammaFactor);
138  read(ritzreader, "MaxKS", ritzery.MaxKS);
139  read(ritzreader, "MaxCG", ritzery.MaxCG);
140  read(ritzreader, "MinKSIter", ritzery.MinKSIter);
141  read(ritzreader, "MaxKSIter", ritzery.MaxKSIter);
142  read(ritzreader, "Nrenorm", ritzery.Nrenorm);
143  }
144  catch( const std::string& e ) {
145  QDPIO::cerr << "Caught exception: " << e << std::endl;
146  QDP_abort(1);
147  }
148 
149  ritzery.Neig = NWilsVec;
150  load_eigenP = false;
151  }
152  else {
153  QDPIO::cerr << "Must specify either Eig for loadable eigenvalues or "
154  << "Ritz Parameters for compuing eigenvalues" << std::endl;
155  QDP_abort(1);
156  }
157 
158  }
159 
160  info.init(ApproxMin,
161  ApproxMax,
162  NWilsVec,
163  load_eigenP,
164  eigen_io,
165  ritzery);
166 
167 }
168 
169 void write(XMLWriter& xml_out, const std::string& path, const OverlapStateInfo& info)
170 {
171 
172  if( path != "." ) {
173  push(xml_out, path);
174  }
175 
176  write( xml_out, "NWilsVec", info.getNWilsVec());
177 
178  if( info.getNWilsVec() == 0 ) {
179  write(xml_out, "ApproxMin", info.getApproxMin());
180  write(xml_out, "ApproxMax", info.getApproxMax());
181  }
182  else {
183  if( info.loadEigVec() ) {
184  write(xml_out, "Eig", info.getEigenIO());
185  }
186  else if ( info.computeEigVec() ) {
187 
188  const RitzParams_t& ritzery = info.getRitzParams();
189 
190  push(xml_out, "Ritz");
191  write(xml_out, "RsdR", ritzery.RsdR);
192  write(xml_out, "RsdA", ritzery.RsdA);
193  write(xml_out, "RsdZero", ritzery.RsdZero);
194  write(xml_out, "ProjApsiP", ritzery.ProjApsiP);
195  write(xml_out, "Ndummy", ritzery.Ndummy);
196  write(xml_out, "GammaFactor", ritzery.GammaFactor);
197  write(xml_out, "MaxKS", ritzery.MaxKS);
198  write(xml_out, "MaxCG", ritzery.MaxCG);
199  write(xml_out, "MinKSIter", ritzery.MinKSIter);
200  write(xml_out, "MaxKSIter", ritzery.MaxKSIter);
201  write(xml_out, "Nrenorm", ritzery.Nrenorm);
202  pop(xml_out);
203 
204  }
205  else {
206  QDPIO::cerr << "Must specify either Eig for loadable eigenvalues or "
207  << "Ritz Parameters for compuing eigenvalues" << std::endl;
208  }
209 
210  }
211 
212  if(path != "." ) {
213  pop(xml_out);
214  }
215 
216 }
217 
218 }
Primary include file for CHROMA library code.
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.
Nd
Definition: meslate.cc:74
Handle< FermBC< LatticeStaggeredFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the FermionAction readers.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
push(xml_out,"Condensates")
pop(xml_out)
static QOP_info_t info
::std::string string
Definition: gtest.h:1979
Struct for dumping the eigenvalues/vectors.
Definition: eigen_io.h:40
std::string eigen_file
Definition: eigen_io.h:42
QDP_volfmt_t eigen_volfmt
Definition: eigen_io.h:43
Struct for parameters needed for a Ritz KS type solve.
Definition: eigen_io.h:22