inline_genprop_matelem_colorvec_w.cc

Go to the documentation of this file.
00001 // $Id: inline_genprop_matelem_colorvec_w.cc,v 1.15 2009/09/14 20:50:14 edwards Exp $
00002 /*! \file
00003  * \brief Compute the matrix element of  LatticeColorVector*M^-1*Gamma*M^-1**LatticeColorVector
00004  *
00005  * Generalized propagator calculation on a colorvector
00006  */
00007 
00008 #include "handle.h"
00009 #include "meas/inline/hadron/inline_genprop_matelem_colorvec_w.h"
00010 #include "meas/inline/abs_inline_measurement_factory.h"
00011 #include "meas/smear/link_smearing_aggregate.h"
00012 #include "meas/smear/link_smearing_factory.h"
00013 #include "meas/smear/displace.h"
00014 #include "meas/glue/mesplq.h"
00015 #include "util/ferm/map_obj.h"
00016 #include "util/ferm/key_val_db.h"
00017 #include "util/ferm/key_prop_colorvec.h"
00018 #include "util/ft/sftmom.h"
00019 #include "util/info/proginfo.h"
00020 #include "meas/inline/make_xml_file.h"
00021 
00022 #include "meas/inline/io/named_objmap.h"
00023 
00024 namespace Chroma 
00025 { 
00026   /*!
00027    * \ingroup hadron
00028    *
00029    * @{
00030    */
00031   namespace InlineGenPropMatElemColorVecEnv 
00032   { 
00033     // Reader for input parameters
00034     void read(XMLReader& xml, const string& path, Params::Param_t::DispGamma_t& param)
00035     {
00036       XMLReader paramtop(xml, path);
00037     
00038       read(paramtop, "gamma", param.gamma);
00039       read(paramtop, "displacement", param.displacement);
00040     }
00041 
00042     // Reader for input parameters
00043     void read(XMLReader& xml, const string& path, Params::Param_t& param)
00044     {
00045       XMLReader paramtop(xml, path);
00046     
00047       int version;
00048       read(paramtop, "version", version);
00049 
00050       switch (version) 
00051       {
00052       case 1:
00053         param.restrict_plateau = false;
00054         param.avg_equiv_mom    = false;
00055         break;
00056 
00057       case 2:
00058         read(paramtop, "restrict_plateau", param.restrict_plateau);
00059         read(paramtop, "avg_equiv_mom", param.avg_equiv_mom);
00060         break;
00061 
00062       default :
00063         QDPIO::cerr << "Input parameter version " << version << " unsupported." << endl;
00064         QDP_abort(1);
00065       }
00066 
00067       read(paramtop, "t_source", param.t_source);
00068       read(paramtop, "t_sink", param.t_sink);
00069       read(paramtop, "mom2_max", param.mom2_max);
00070       read(paramtop, "mom_offset", param.mom_offset);
00071       read(paramtop, "displacement_length", param.displacement_length);
00072       read(paramtop, "DisplacementGammaList", param.disp_gamma_list);
00073       read(paramtop, "num_vecs", param.num_vecs);
00074       read(paramtop, "decay_dir", param.decay_dir);
00075       read(paramtop, "mass_label", param.mass_label);
00076 
00077       param.link_smearing  = readXMLGroup(paramtop, "LinkSmearing", "LinkSmearingType");
00078     }
00079 
00080 
00081     // Writer for input parameters
00082     void write(XMLWriter& xml, const string& path, const Params::Param_t::DispGamma_t& param)
00083     {
00084       push(xml, path);
00085 
00086       write(xml, "gamma", param.gamma);
00087       write(xml, "displacement", param.displacement);
00088 
00089       pop(xml);
00090     }
00091 
00092     // Writer for input parameters
00093     void write(XMLWriter& xml, const string& path, const Params::Param_t& param)
00094     {
00095       push(xml, path);
00096 
00097       int version = 2;
00098 
00099       write(xml, "version", version);
00100       write(xml, "restrict_plateau", param.restrict_plateau);
00101       write(xml, "avg_equiv_mom", param.avg_equiv_mom);
00102       write(xml, "t_source", param.t_source);
00103       write(xml, "t_sink", param.t_sink);
00104       write(xml, "mom_offset", param.mom_offset);
00105       write(xml, "mom2_max", param.mom2_max);
00106       write(xml, "displacement_length", param.displacement_length);
00107       write(xml, "DisplacementGammaList", param.disp_gamma_list);
00108       write(xml, "num_vecs", param.num_vecs);
00109       write(xml, "decay_dir", param.decay_dir);
00110       write(xml, "mass_label", param.mass_label);
00111 
00112       xml << param.link_smearing.xml;
00113 
00114       pop(xml);
00115     }
00116 
00117     //! Read named objects 
00118     void read(XMLReader& xml, const string& path, Params::NamedObject_t& input)
00119     {
00120       XMLReader inputtop(xml, path);
00121 
00122       read(inputtop, "gauge_id", input.gauge_id);
00123       read(inputtop, "source_prop_id", input.source_prop_id);
00124       read(inputtop, "sink_prop_id", input.sink_prop_id);
00125       read(inputtop, "genprop_op_file", input.genprop_op_file);
00126     }
00127 
00128     //! Write named objects
00129     void write(XMLWriter& xml, const string& path, const Params::NamedObject_t& input)
00130     {
00131       push(xml, path);
00132 
00133       write(xml, "gauge_id", input.gauge_id);
00134       write(xml, "source_prop_id", input.source_prop_id);
00135       write(xml, "sink_prop_id", input.sink_prop_id);
00136       write(xml, "genprop_op_file", input.genprop_op_file);
00137 
00138       pop(xml);
00139     }
00140 
00141     // Writer for input parameters
00142     void write(XMLWriter& xml, const string& path, const Params& param)
00143     {
00144       param.writeXML(xml, path);
00145     }
00146   }
00147 
00148 
00149   namespace InlineGenPropMatElemColorVecEnv 
00150   { 
00151     // Anonymous namespace for registration
00152     namespace
00153     {
00154       AbsInlineMeasurement* createMeasurement(XMLReader& xml_in, 
00155                                               const std::string& path) 
00156       {
00157         return new InlineMeas(Params(xml_in, path));
00158       }
00159 
00160       //! Local registration flag
00161       bool registered = false;
00162     }
00163 
00164     const std::string name = "GENPROP_MATELEM_COLORVEC";
00165 
00166     //! Register all the factories
00167     bool registerAll() 
00168     {
00169       bool success = true; 
00170       if (! registered)
00171       {
00172         success &= LinkSmearingEnv::registerAll();
00173         success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
00174         registered = true;
00175       }
00176       return success;
00177     }
00178 
00179 
00180     //! Anonymous namespace
00181     /*! Diagnostic stuff */
00182     namespace
00183     {
00184       StandardOutputStream& operator<<(StandardOutputStream& os, const multi1d<int>& d)
00185       {
00186         if (d.size() > 0)
00187         {
00188           os << d[0];
00189 
00190           for(int i=1; i < d.size(); ++i)
00191             os << " " << d[i];
00192         }
00193 
00194         return os;
00195       }
00196     }
00197 
00198 
00199     //----------------------------------------------------------------------------
00200     // Param stuff
00201     Params::Params()
00202     { 
00203       frequency = 0; 
00204       param.mom2_max = 0;
00205     }
00206 
00207     Params::Params(XMLReader& xml_in, const std::string& path) 
00208     {
00209       try 
00210       {
00211         XMLReader paramtop(xml_in, path);
00212 
00213         if (paramtop.count("Frequency") == 1)
00214           read(paramtop, "Frequency", frequency);
00215         else
00216           frequency = 1;
00217 
00218         // Read program parameters
00219         read(paramtop, "Param", param);
00220 
00221         // Read in the output propagator/source configuration info
00222         read(paramtop, "NamedObject", named_obj);
00223 
00224         // Possible alternate XML file pattern
00225         if (paramtop.count("xml_file") != 0) 
00226         {
00227           read(paramtop, "xml_file", xml_file);
00228         }
00229       }
00230       catch(const std::string& e) 
00231       {
00232         QDPIO::cerr << __func__ << ": Caught Exception reading XML: " << e << endl;
00233         QDP_abort(1);
00234       }
00235     }
00236 
00237 
00238     void
00239     Params::writeXML(XMLWriter& xml_out, const std::string& path) const
00240     {
00241       push(xml_out, path);
00242     
00243       // Parameters for source construction
00244       write(xml_out, "Param", param);
00245 
00246       // Write out the output propagator/source configuration info
00247       write(xml_out, "NamedObject", named_obj);
00248 
00249       pop(xml_out);
00250     }
00251 
00252 
00253     //----------------------------------------------------------------------------
00254     //! Generalized propagator operator
00255     struct KeyGenPropElementalOperator_t
00256     {
00257       int                t_slice;       /*!< Propagator time slice */
00258       int                t_source;      /*!< Source time slice */
00259       int                t_sink;        /*!< Source time slice */
00260       int                spin_l;        /*!< Source spin index */
00261       int                spin_r;        /*!< Sink spin index */
00262       int                gamma;         /*!< The gamma matrix number - [0,Ns^2) */
00263       multi1d<int>       displacement;  /*!< Displacement dirs of right colorvector */
00264       multi1d<int>       mom;           /*!< D-1 momentum of this operator */
00265       std::string        mass_label;    /*!< A mass label */
00266     };
00267 
00268     //! Generalized propagator operator
00269     struct ValGenPropElementalOperator_t
00270     {
00271       multi2d<ComplexD>  op;              /*!< Colorvector source and sink with momentum projection */
00272     };
00273 
00274 
00275     //----------------------------------------------------------------------------
00276     //! Holds key and value as temporaries
00277     struct KeyValGenPropElementalOperator_t
00278     {
00279       SerialDBKey<KeyGenPropElementalOperator_t>  key;
00280       SerialDBData<ValGenPropElementalOperator_t> val;
00281     };
00282 
00283 
00284     //----------------------------------------------------------------------------
00285     //! KeyGenPropElementalOperator reader
00286     void read(BinaryReader& bin, KeyGenPropElementalOperator_t& param)
00287     {
00288       read(bin, param.t_slice);
00289       read(bin, param.t_source);
00290       read(bin, param.t_sink);
00291       read(bin, param.spin_l);
00292       read(bin, param.spin_r);
00293       read(bin, param.gamma);
00294       read(bin, param.displacement);
00295       read(bin, param.mom);
00296       read(bin, param.mass_label, 32);
00297     }
00298 
00299     //! GenPropElementalOperator write
00300     void write(BinaryWriter& bin, const KeyGenPropElementalOperator_t& param)
00301     {
00302       write(bin, param.t_slice);
00303       write(bin, param.t_source);
00304       write(bin, param.t_sink);
00305       write(bin, param.spin_l);
00306       write(bin, param.spin_r);
00307       write(bin, param.gamma);
00308       write(bin, param.displacement);
00309       write(bin, param.mom);
00310       write(bin, param.mass_label);
00311     }
00312 
00313 
00314     //----------------------------------------------------------------------------
00315     //! PropElementalOperator reader
00316     void read(BinaryReader& bin, ValGenPropElementalOperator_t& param)
00317     {
00318       int n;
00319       read(bin, n);    // the size is always written, even if 0
00320       param.op.resize(n,n);
00321   
00322       for(int i=0; i < n; ++i)
00323       {
00324         for(int j=0; j < n; ++j)
00325         {
00326           read(bin, param.op(i,j));
00327         }
00328       }
00329     }
00330 
00331     //! GenPropElementalOperator write
00332     void write(BinaryWriter& bin, const ValGenPropElementalOperator_t& param)
00333     {
00334       int n = param.op.size1();  // all sizes the same
00335       write(bin, n);
00336       for(int i=0; i < n; ++i)
00337       {
00338         for(int j=0; j < n; ++j)
00339         {
00340           write(bin, param.op(i,j));
00341         }
00342       }
00343     }
00344 
00345 
00346     //----------------------------------------------------------------------------
00347     //! Normalize just one displacement array
00348     multi1d<int> normDisp(const multi1d<int>& orig)
00349     {
00350       START_CODE();
00351 
00352       multi1d<int> disp;
00353       multi1d<int> empty; 
00354       multi1d<int> no_disp(1); no_disp[0] = 0;
00355 
00356       // NOTE: a no-displacement is recorded as a zero-length array
00357       // Convert a length one array with no displacement into a no-displacement array
00358       if (orig.size() == 1)
00359       {
00360         if (orig == no_disp)
00361           disp = empty;
00362         else
00363           disp = orig;
00364       }
00365       else
00366       {
00367         disp = orig;
00368       }
00369 
00370       END_CODE();
00371 
00372       return disp;
00373     } // void normDisp
00374 
00375 
00376     //-------------------------------------------------------------------------------
00377     // Function call
00378     void 
00379     InlineMeas::operator()(unsigned long update_no,
00380                            XMLWriter& xml_out) 
00381     {
00382       // If xml file not empty, then use alternate
00383       if (params.xml_file != "")
00384       {
00385         string xml_file = makeXMLFileName(params.xml_file, update_no);
00386 
00387         push(xml_out, "GenPropMatElemColorVec");
00388         write(xml_out, "update_no", update_no);
00389         write(xml_out, "xml_file", xml_file);
00390         pop(xml_out);
00391 
00392         XMLFileWriter xml(xml_file);
00393         func(update_no, xml);
00394       }
00395       else
00396       {
00397         func(update_no, xml_out);
00398       }
00399     }
00400 
00401 
00402     // Function call
00403     void 
00404     InlineMeas::func(unsigned long update_no,
00405                      XMLWriter& xml_out) 
00406     {
00407       START_CODE();
00408 
00409       StopWatch snoop;
00410       snoop.reset();
00411       snoop.start();
00412 
00413       StopWatch swiss;
00414                         
00415       push(xml_out, "GenPropMatElemColorVec");
00416       write(xml_out, "update_no", update_no);
00417 
00418       QDPIO::cout << name << ": Generalized propagator color-vector matrix element" << endl;
00419 
00420       // Test and grab a reference to the gauge field
00421       XMLBufferWriter gauge_xml;
00422       XMLReader source_prop_file_xml, source_prop_record_xml;
00423       XMLReader sink_prop_file_xml, sink_prop_record_xml;
00424       try
00425       {
00426         TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
00427         TheNamedObjMap::Instance().get(params.named_obj.gauge_id).getRecordXML(gauge_xml);
00428 
00429         TheNamedObjMap::Instance().getData< MapObject<KeyPropColorVec_t,LatticeFermion> >(params.named_obj.source_prop_id);
00430         TheNamedObjMap::Instance().getData< MapObject<KeyPropColorVec_t,LatticeFermion> >(params.named_obj.sink_prop_id);
00431 
00432         // Snarf the prop info. This is will throw if the prop_id is not there
00433         TheNamedObjMap::Instance().get(params.named_obj.source_prop_id).getFileXML(source_prop_file_xml);
00434         TheNamedObjMap::Instance().get(params.named_obj.source_prop_id).getRecordXML(source_prop_record_xml);
00435 
00436         // Snarf the prop info. This is will throw if the prop_id is not there
00437         TheNamedObjMap::Instance().get(params.named_obj.sink_prop_id).getFileXML(sink_prop_file_xml);
00438         TheNamedObjMap::Instance().get(params.named_obj.sink_prop_id).getRecordXML(sink_prop_record_xml);
00439       }
00440       catch( std::bad_cast ) 
00441       {
00442         QDPIO::cerr << name << ": caught dynamic cast error" << endl;
00443         QDP_abort(1);
00444       }
00445       catch (const string& e) 
00446       {
00447         QDPIO::cerr << name << ": map call failed: " << e << endl;
00448         QDP_abort(1);
00449       }
00450       // Cast should be valid now
00451       const multi1d<LatticeColorMatrix>& u = 
00452         TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
00453 
00454       const MapObject<KeyPropColorVec_t,LatticeFermion>& source_ferm_map =
00455         TheNamedObjMap::Instance().getData< MapObject<KeyPropColorVec_t,LatticeFermion> >(params.named_obj.source_prop_id);
00456       const MapObject<KeyPropColorVec_t,LatticeFermion>& sink_ferm_map =
00457         TheNamedObjMap::Instance().getData< MapObject<KeyPropColorVec_t,LatticeFermion> >(params.named_obj.sink_prop_id);
00458 
00459       push(xml_out, "Output_version");
00460       write(xml_out, "out_version", 2);
00461       pop(xml_out);
00462 
00463       proginfo(xml_out);    // Print out basic program info
00464 
00465       // Write out the input
00466       params.writeXML(xml_out, "Input");
00467 
00468       // Write out the source header
00469       write(xml_out, "Source_prop_file_info", source_prop_file_xml);
00470       write(xml_out, "Source_prop_record_info", source_prop_record_xml);
00471       write(xml_out, "Sink_prop_file_info", sink_prop_file_xml);
00472       write(xml_out, "Sink_prop_record_info", sink_prop_record_xml);
00473 
00474       // Write out the config info
00475       write(xml_out, "Config_info", gauge_xml);
00476 
00477       //First calculate some gauge invariant observables just for info.
00478       //This is really cheap.
00479       MesPlq(xml_out, "Observables", u);
00480 
00481       //
00482       // Initialize the slow Fourier transform phases
00483       //
00484       multi1d<int> origin_offset(Nd);
00485       origin_offset = 0;
00486       SftMom phases(params.param.mom2_max, origin_offset, params.param.mom_offset, 
00487                     params.param.avg_equiv_mom, params.param.decay_dir);
00488 
00489       //
00490       // Smear the gauge field if needed
00491       //
00492       multi1d<LatticeColorMatrix> u_smr = u;
00493 
00494       try
00495       {
00496         std::istringstream  xml_l(params.param.link_smearing.xml);
00497         XMLReader  linktop(xml_l);
00498         QDPIO::cout << "Link smearing type = " << params.param.link_smearing.id << endl;
00499         
00500         
00501         Handle< LinkSmearing >
00502           linkSmearing(TheLinkSmearingFactory::Instance().createObject(params.param.link_smearing.id,
00503                                                                        linktop, 
00504                                                                        params.param.link_smearing.path));
00505 
00506         (*linkSmearing)(u_smr);
00507       }
00508       catch(const std::string& e) 
00509       {
00510         QDPIO::cerr << name << ": Caught Exception link smearing: " << e << endl;
00511         QDP_abort(1);
00512       }
00513 
00514       MesPlq(xml_out, "Smeared_Observables", u_smr);
00515 
00516       //
00517       // DB storage
00518       //
00519       BinaryStoreDB< SerialDBKey<KeyGenPropElementalOperator_t>, SerialDBData<ValGenPropElementalOperator_t> > 
00520         qdp_db;
00521 
00522       // Open the file, and write the meta-data and the binary for this operator
00523       if (! qdp_db.fileExists(params.named_obj.genprop_op_file))
00524       {
00525         XMLBufferWriter file_xml;
00526 
00527         push(file_xml, "DBMetaData");
00528         write(file_xml, "id", string("genPropElemOp"));
00529         write(file_xml, "lattSize", QDP::Layout::lattSize());
00530         write(file_xml, "decay_dir", params.param.decay_dir);
00531         proginfo(file_xml);    // Print out basic program info
00532         write(file_xml, "Params", params.param);
00533         write(file_xml, "Op_Info", params.param.disp_gamma_list);
00534         write(file_xml, "Source_prop_record_info", source_prop_record_xml);
00535         write(file_xml, "Sink_prop_record_info", sink_prop_record_xml);
00536         write(file_xml, "Config_info", gauge_xml);
00537         pop(file_xml);
00538 
00539         // NOTE: we always write a metadata, even if the file exists. 
00540         // Probably should not do this if a file already exists.
00541         // Yukky, but add on a bunch of padding. 
00542         // This is in case a latter task writes another metadata.
00543         std::string file_str(file_xml.str());
00544         qdp_db.setMaxUserInfoLen(file_str.size());
00545 
00546         qdp_db.open(params.named_obj.genprop_op_file, O_RDWR | O_CREAT, 0664);
00547 
00548         qdp_db.insertUserdata(file_str);
00549       }
00550       else
00551       {
00552         qdp_db.open(params.named_obj.genprop_op_file, O_RDWR, 0664);
00553       }
00554 
00555 
00556       //
00557       // Generalized propagatos
00558       //
00559       QDPIO::cout << "Building generalized propagators" << endl;
00560 
00561       push(xml_out, "ElementalOps");
00562 
00563       // Loop over all time slices for the source. This is the same 
00564       // as the subsets for  phases
00565 
00566       const bool restrict_plateau = params.param.restrict_plateau;
00567       const int num_vecs          = params.param.num_vecs;
00568       const int decay_dir         = params.param.decay_dir;
00569       const int t_source          = params.param.t_source;
00570       const int t_sink            = params.param.t_sink;
00571 
00572       // Define the start and end region for the plateau
00573       int t_start;
00574       int t_end;
00575 
00576       if (restrict_plateau)
00577       {
00578         t_start = t_source;
00579         t_end   = t_sink;
00580 
00581         if (t_source > t_sink)
00582         {
00583           t_end += phases.numSubsets();
00584         }
00585       }
00586       else
00587       {
00588         t_start = 0;
00589         t_end   = phases.numSubsets() - 1;
00590       }
00591 
00592       // Loop over each operator 
00593       for(int l=0; l < params.param.disp_gamma_list.size(); ++l)
00594       {
00595         StopWatch watch;
00596 
00597         QDPIO::cout << "Elemental operator: op = " << l << endl;
00598 
00599         // Make sure displacement is something sensible
00600         multi1d<int> disp = normDisp(params.param.disp_gamma_list[l].displacement);
00601 
00602         // Fold in the gamma_5 associated with hermiticity of the sink. 
00603         // Can multiply the desired Gamma on the left by gamma_5
00604         int gamma = params.param.disp_gamma_list[l].gamma;
00605         int gamma_tmp = (Ns*Ns-1) ^ gamma;
00606 
00607         QDPIO::cout << "gamma=" << gamma_tmp << "  displacement= " << disp << endl;
00608 
00609         // Build the operator
00610         swiss.reset();
00611         swiss.start();
00612 
00613         // Big loop over the momentum projection
00614         for(int mom_num = 0 ; mom_num < phases.numMom() ; ++mom_num) 
00615         {
00616           // Loop over spins
00617           for(int spin_r=0; spin_r < Ns; ++spin_r)
00618           {
00619             QDPIO::cout << "spin_r = " << spin_r << endl; 
00620 
00621             for(int spin_l=0; spin_l < Ns; ++spin_l)
00622             {
00623               QDPIO::cout << "spin_l = " << spin_l << endl; 
00624 
00625               // The keys for the spin and displacements for this particular elemental operator
00626               // No displacement for left colorvector, only displace right colorvector
00627               // Invert the time - make it an independent key
00628               multi1d<KeyValGenPropElementalOperator_t> buf(phases.numSubsets());
00629               for(int tt=t_start; tt <= t_end; ++tt)
00630               {
00631                 int t = tt % phases.numSubsets(); // mod back into a normal interval
00632 
00633                 buf[t].key.key().t_slice       = t;
00634                 buf[t].key.key().t_source      = t_source;
00635                 buf[t].key.key().t_sink        = t_sink;
00636                 buf[t].key.key().spin_r        = spin_r;
00637                 buf[t].key.key().spin_l        = spin_l;
00638                 buf[t].key.key().mass_label    = params.param.mass_label;
00639                 buf[t].key.key().mom           = phases.numToMom(mom_num);
00640                 buf[t].key.key().gamma         = gamma;
00641                 buf[t].key.key().displacement  = disp; // only right colorvector
00642 
00643                 buf[t].val.data().op.resize(num_vecs, num_vecs);
00644               }
00645 
00646               for(int j = 0; j < params.param.num_vecs; ++j)
00647               {
00648                 KeyPropColorVec_t key_r;
00649                 key_r.t_source     = t_source;
00650                 key_r.colorvec_src = j;
00651                 key_r.spin_src     = spin_r;
00652                   
00653                 // Displace the right vector and multiply by the momentum phase
00654                 LatticeFermion shift_ferm = Gamma(gamma_tmp) * displace(u_smr, 
00655                                                                         source_ferm_map[key_r],
00656                                                                         params.param.displacement_length, 
00657                                                                         disp);
00658 
00659                 for(int i = 0; i < params.param.num_vecs; ++i)
00660                 {
00661                   KeyPropColorVec_t key_l;
00662                   key_l.t_source     = t_sink;
00663                   key_l.colorvec_src = i;
00664                   key_l.spin_src     = spin_l;
00665                   
00666                   watch.reset();
00667                   watch.start();
00668 
00669                   // Contract over color indices
00670                   // Do the relevant quark contraction
00671                   LatticeComplex lop = localInnerProduct(sink_ferm_map[key_l], shift_ferm);
00672 
00673                   // Reweight the phase in case there was momentum averaging
00674                   Real reweight;
00675                   if (phases.multiplicity(mom_num) > 0)
00676                     reweight = Real(phases.multiplicity(mom_num));
00677                   else
00678                     reweight = 1.0;
00679 
00680                   // Slow fourier-transform
00681                   multi1d<ComplexD> op_sum = sumMulti(reweight * phases[mom_num] * lop, phases.getSet());
00682 
00683                   watch.stop();
00684 
00685                   for(int tt=t_start; tt <= t_end; ++tt)
00686                   {
00687                     int t = tt % phases.numSubsets(); // mod back into a normal interval
00688                     buf[t].val.data().op(i,j) = op_sum[t];
00689                   }
00690                 } // end for i
00691               } // end for j
00692 
00693               QDPIO::cout << "insert: mom= " << phases.numToMom(mom_num) << " displacement= " << disp << endl; 
00694               for(int tt=t_start; tt <= t_end; ++tt)
00695               {
00696                 int t = tt % phases.numSubsets(); // mod back into a normal interval
00697                 qdp_db.insert(buf[t].key, buf[t].val);
00698               }
00699 
00700             } // end for spin_l
00701           } // end for spin_r
00702         } // mom_num
00703 
00704         swiss.stop();
00705 
00706         QDPIO::cout << "GenProp operator= " << l 
00707                     << "  time= "
00708                     << swiss.getTimeInSeconds() 
00709                     << " secs" << endl;
00710 
00711       } // for l
00712 
00713       pop(xml_out); // ElementalOps
00714 
00715       // Close the namelist output file XMLDAT
00716       pop(xml_out);     // GenPropMatElemColorVector
00717 
00718       snoop.stop();
00719       QDPIO::cout << name << ": total time = " 
00720                   << snoop.getTimeInSeconds() 
00721                   << " secs" << endl;
00722 
00723       QDPIO::cout << name << ": ran successfully" << endl;
00724 
00725       END_CODE();
00726     } // func
00727   } // namespace InlineGenPropMatElemColorVecEnv
00728 
00729   /*! @} */  // end of group hadron
00730 
00731 } // namespace Chroma

Generated on Sun Nov 22 04:32:31 2009 for CHROMA by  doxygen 1.4.7