read_rat_approx.cc

Go to the documentation of this file.
00001 #include "chromabase.h"
00002 #include "update/molecdyn/monomial/read_rat_approx.h"
00003 #include "update/molecdyn/monomial/rat_approx_factory.h"
00004 #include "update/molecdyn/monomial/rat_approx_aggregate.h"
00005 
00006 namespace Chroma { 
00007 
00008   namespace ReadRatApproxEnv
00009   {
00010     //! Callback function
00011     RationalApprox* createApprox(XMLReader& xml_in,
00012                                  const std::string& path)
00013     {
00014       QDPIO::cout << " XML Is: " << endl;
00015       xml_in.print(std::cout);
00016       QDPIO::cout << endl <<flush ;
00017       return new ReadRatApprox(Params(xml_in, path));
00018     }
00019 
00020     
00021     //! Name to be used
00022     const std::string name = "READ_COEFFS";
00023 
00024     //! Local registration flag
00025     static bool registered = false;
00026 
00027     //! Register all the factories
00028     bool registerAll() 
00029     {
00030       bool success = true; 
00031       if (! registered)
00032       {
00033         success &= Chroma::TheRationalApproxFactory::Instance().registerObject(name, createApprox);
00034         registered = true;
00035       }
00036       return success;
00037     }
00038 
00039     //! Params for Remez type rational approximation
00040     /*! @ingroup monomial */
00041     Params::Params(XMLReader& in, const std::string& path) { 
00042       
00043       try { 
00044         XMLReader paramtop(in,path);
00045 
00046        
00047         XMLReader pfe_in(paramtop, "PFECoeffs");
00048         read(pfe_in, "norm", pfe.norm);
00049         read(pfe_in, "res", pfe.res);
00050         read(pfe_in, "pole", pfe.pole);
00051         XMLReader ipfe_in(paramtop, "IPFECoeffs");
00052         read(ipfe_in, "norm", ipfe.norm);
00053         read(ipfe_in, "res", ipfe.res);
00054         read(ipfe_in, "pole", ipfe.pole);
00055       }
00056       catch(const std::string& e) { 
00057         QDPIO::cout << "Caught Exception reading XML" << e << endl;
00058         QDP_abort(1);
00059       }
00060     }
00061 
00062     void Params::writeXML(XMLWriter& out, const std::string& path) const {
00063       push(out, path);
00064       push(out, "PFECoeffs");
00065       write(out, "norm", pfe.norm);
00066       write(out, "res", pfe.res);
00067       write(out, "pole", pfe.pole);
00068       pop(out);
00069       push(out, "IPFECoeffs");
00070       write(out, "norm", ipfe.norm);
00071       write(out, "res",  ipfe.res);
00072       write(out, "pole", ipfe.pole);
00073       pop(out);
00074 
00075     }
00076 
00077 
00078     
00079   }; // Namespace   
00080 
00081   void read(XMLReader &xml, const string& path, ReadRatApproxEnv::Params& param) {
00082     ReadRatApproxEnv::Params tmp(xml, path);
00083     param=tmp;
00084   }
00085 
00086  //! Write Parameters
00087   void write(XMLWriter& xml, const std::string& path, const ReadRatApproxEnv::Params& param) 
00088   {
00089     param.writeXML(xml, path);
00090   }
00091 
00092 
00093   void ReadRatApprox::operator()(RemezCoeff_t& pfe, RemezCoeff_t& ipfe) const 
00094   {
00095     pfe=params.pfe;
00096     ipfe=params.ipfe;
00097   }
00098 
00099 };

Generated on Mon Mar 15 04:34:28 2010 for CHROMA by  doxygen 1.4.7