inline_baryon_block_matelem_w.cc

Go to the documentation of this file.
00001 // $Id: inline_baryon_block_matelem_w.cc,v 1.9 2009/09/14 21:05:54 edwards Exp $
00002 /*! \file
00003  * \brief Inline measurement of baryon operators via colorvector matrix elements
00004  */
00005 
00006 #include "handle.h"
00007 #include "meas/inline/hadron/inline_baryon_block_matelem_w.h"
00008 #include "meas/inline/abs_inline_measurement_factory.h"
00009 #include "meas/smear/link_smearing_aggregate.h"
00010 #include "meas/smear/link_smearing_factory.h"
00011 #include "meas/glue/mesplq.h"
00012 #include "meas/smear/disp_colvec_map.h"
00013 #include "util/ferm/block_subset.h"
00014 #include "util/ferm/block_couplings.h"
00015 #include "util/ferm/subset_vectors.h"
00016 #include "util/ferm/key_val_db.h"
00017 #include "util/ft/sftmom.h"
00018 #include "util/info/proginfo.h"
00019 #include "meas/inline/make_xml_file.h"
00020 
00021 #include "meas/inline/io/named_objmap.h"
00022 
00023 #define COLORVEC_MATELEM_TYPE_ZERO       0
00024 #define COLORVEC_MATELEM_TYPE_ONE        1
00025 #define COLORVEC_MATELEM_TYPE_MONE       -1
00026 #define COLORVEC_MATELEM_TYPE_GENERIC    10
00027 
00028 namespace Chroma 
00029 { 
00030   /*!
00031    * \ingroup hadron
00032    *
00033    * @{
00034    */
00035   namespace InlineBaryonBlockMatElemEnv 
00036   { 
00037     // Reader for input parameters
00038     void read(XMLReader& xml, const string& path, InlineBaryonBlockMatElemEnv::Params::Param_t::Displacement_t& param)
00039     {
00040       XMLReader paramtop(xml, path);
00041 
00042       read(paramtop, "left", param.left);
00043       read(paramtop, "middle", param.middle);
00044       read(paramtop, "right", param.right);
00045     }
00046 
00047 
00048     // Writer for input parameters
00049     void write(XMLWriter& xml, const string& path, const InlineBaryonBlockMatElemEnv::Params::Param_t::Displacement_t& param)
00050     {
00051       push(xml, path);
00052 
00053       write(xml, "left", param.left);
00054       write(xml, "middle", param.middle);
00055       write(xml, "right", param.right);
00056 
00057       pop(xml);
00058     }
00059 
00060 
00061     // Reader for input parameters
00062     void read(XMLReader& xml, const string& path, InlineBaryonBlockMatElemEnv::Params::Param_t& param)
00063     {
00064       XMLReader paramtop(xml, path);
00065     
00066       int version;
00067       read(paramtop, "version", version);
00068 
00069       switch (version) 
00070       {
00071       case 1:
00072         /**************************************************************************/
00073         break;
00074 
00075       default :
00076         /**************************************************************************/
00077 
00078         QDPIO::cerr << "Input parameter version " << version << " unsupported." << endl;
00079         QDP_abort(1);
00080       }
00081 
00082       read(paramtop, "mom2_max", param.mom2_max);
00083       read(paramtop, "displacement_length", param.displacement_length);
00084       read(paramtop, "displacement_list", param.displacement_list);
00085       read(paramtop, "num_vecs", param.num_vecs);
00086       read(paramtop, "decay_dir", param.decay_dir);
00087       read(paramtop, "block_size", param.block_size);
00088       read(paramtop, "site_orthog_basis", param.site_orthog_basis);
00089 
00090       param.link_smearing  = readXMLGroup(paramtop, "LinkSmearing", "LinkSmearingType");
00091     }
00092 
00093 
00094     // Writer for input parameters
00095     void write(XMLWriter& xml, const string& path, const InlineBaryonBlockMatElemEnv::Params::Param_t& param)
00096     {
00097       push(xml, path);
00098 
00099       int version = 1;
00100 
00101       write(xml, "version", version);
00102       write(xml, "mom2_max", param.mom2_max);
00103       write(xml, "displacement_length", param.displacement_length);
00104       write(xml, "displacement_list", param.displacement_list);
00105       write(xml, "num_vecs", param.num_vecs);
00106       write(xml, "decay_dir", param.decay_dir);
00107       write(xml, "block_size", param.block_size);
00108       write(xml, "site_orthog_basis", param.site_orthog_basis);
00109       xml << param.link_smearing.xml;
00110 
00111       pop(xml);
00112     }
00113 
00114     //! Read named objects 
00115     void read(XMLReader& xml, const string& path, InlineBaryonBlockMatElemEnv::Params::NamedObject_t& input)
00116     {
00117       XMLReader inputtop(xml, path);
00118 
00119       read(inputtop, "gauge_id", input.gauge_id);
00120       read(inputtop, "colorvec_id", input.colorvec_id);
00121       read(inputtop, "baryon_op_file", input.baryon_op_file);
00122     }
00123 
00124     //! Write named objects
00125     void write(XMLWriter& xml, const string& path, const InlineBaryonBlockMatElemEnv::Params::NamedObject_t& input)
00126     {
00127       push(xml, path);
00128 
00129       write(xml, "gauge_id", input.gauge_id);
00130       write(xml, "colorvec_id", input.colorvec_id);
00131       write(xml, "baryon_op_file", input.baryon_op_file);
00132 
00133       pop(xml);
00134     }
00135 
00136     // Writer for input parameters
00137     void write(XMLWriter& xml, const string& path, const InlineBaryonBlockMatElemEnv::Params& param)
00138     {
00139       param.writeXML(xml, path);
00140     }
00141   }
00142 
00143 
00144   namespace InlineBaryonBlockMatElemEnv 
00145   { 
00146     // Anonymous namespace for registration
00147     namespace
00148     {
00149       AbsInlineMeasurement* createMeasurement(XMLReader& xml_in, 
00150                                               const std::string& path) 
00151       {
00152         return new InlineMeas(Params(xml_in, path));
00153       }
00154 
00155       //! Local registration flag
00156       bool registered = false;
00157     }
00158 
00159     const std::string name = "BARYON_BLOCK_MATELEM";
00160 
00161     //! Register all the factories
00162     bool registerAll() 
00163     {
00164       bool success = true; 
00165       if (! registered)
00166       {
00167         success &= LinkSmearingEnv::registerAll();
00168         success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
00169         registered = true;
00170       }
00171       return success;
00172     }
00173 
00174 
00175     //! Anonymous namespace
00176     /*! Diagnostic stuff */
00177     namespace
00178     {
00179       StandardOutputStream& operator<<(StandardOutputStream& os, const multi1d<int>& d)
00180       {
00181         if (d.size() > 0)
00182         {
00183           os << d[0];
00184 
00185           for(int i=1; i < d.size(); ++i)
00186             os << " " << d[i];
00187         }
00188 
00189         return os;
00190       }
00191 
00192       StandardOutputStream& operator<<(StandardOutputStream& os, const Params::Param_t::Displacement_t& d)
00193       {
00194         os << "left= " << d.left 
00195            << " middle= " << d.middle
00196            << " right= " << d.right;
00197 
00198         return os;
00199       }
00200     }
00201 
00202 
00203     //----------------------------------------------------------------------------
00204     // Param stuff
00205     Params::Params()
00206     { 
00207       frequency = 0; 
00208       param.mom2_max = 0;
00209     }
00210 
00211     Params::Params(XMLReader& xml_in, const std::string& path) 
00212     {
00213       try 
00214       {
00215         XMLReader paramtop(xml_in, path);
00216 
00217         if (paramtop.count("Frequency") == 1)
00218           read(paramtop, "Frequency", frequency);
00219         else
00220           frequency = 1;
00221 
00222         // Read program parameters
00223         read(paramtop, "Param", param);
00224 
00225         // Read in the output propagator/source configuration info
00226         read(paramtop, "NamedObject", named_obj);
00227 
00228         // Possible alternate XML file pattern
00229         if (paramtop.count("xml_file") != 0) 
00230         {
00231           read(paramtop, "xml_file", xml_file);
00232         }
00233       }
00234       catch(const std::string& e) 
00235       {
00236         QDPIO::cerr << __func__ << ": Caught Exception reading XML: " << e << endl;
00237         QDP_abort(1);
00238       }
00239     }
00240 
00241 
00242     void
00243     Params::writeXML(XMLWriter& xml_out, const std::string& path) const
00244     {
00245       push(xml_out, path);
00246     
00247       // Parameters for source construction
00248       write(xml_out, "Param", param);
00249 
00250       // Write out the output propagator/source configuration info
00251       write(xml_out, "NamedObject", named_obj);
00252 
00253       pop(xml_out);
00254     }
00255 
00256 
00257     //----------------------------------------------------------------------------
00258     //! Baryon operator
00259     struct KeyBaryonElementalOperator_t
00260     {
00261       int                t_slice;      /*!< Baryon operator time slice */
00262       int                displacement_length; /*!< Displacement length for creat. and annih. ops */
00263       multi1d<int>       left;         /*!< Displacement dirs of left colorvector */
00264       multi1d<int>       middle;       /*!< Displacement dirs of middle colorvector */
00265       multi1d<int>       right;        /*!< Displacement dirs of right colorvector */
00266       multi1d<int>       mom;          /*!< D-1 momentum of this operator */
00267       int                blk_l;        /*!< Block of the left quark */
00268       int                blk_m;        /*!< Block for the middle quark */
00269       int                blk_r;        /*!< Block for the right quark */
00270     };
00271 
00272     //! Baryon operator
00273     struct ValBaryonElementalOperator_t
00274     {
00275       int                type_of_data; /*!< Flag indicating type of data (maybe trivial) */
00276       multi3d<ComplexD>  op;           /*!< Momentum projected operator */
00277     };
00278 
00279 
00280     //----------------------------------------------------------------------------
00281     //! Holds key and value as temporaries
00282     struct KeyValBaryonElementalOperator_t
00283     {
00284       SerialDBKey<KeyBaryonElementalOperator_t>  key;
00285       SerialDBData<ValBaryonElementalOperator_t> val;
00286     };
00287 
00288 
00289     //----------------------------------------------------------------------------
00290     //! BaryonElementalOperator reader
00291     void read(BinaryReader& bin, KeyBaryonElementalOperator_t& param)
00292     {
00293       read(bin, param.t_slice);
00294       read(bin, param.displacement_length);
00295       read(bin, param.left);
00296       read(bin, param.middle);
00297       read(bin, param.right);
00298       read(bin, param.mom);
00299       read(bin, param.blk_l);
00300       read(bin, param.blk_m);
00301       read(bin, param.blk_r);
00302     }
00303 
00304     //! BaryonElementalOperator write
00305     void write(BinaryWriter& bin, const KeyBaryonElementalOperator_t& param)
00306     {
00307       write(bin, param.t_slice);
00308       write(bin, param.displacement_length);
00309       write(bin, param.left);
00310       write(bin, param.middle);
00311       write(bin, param.right);
00312       write(bin, param.mom);
00313       write(bin, param.blk_l);
00314       write(bin, param.blk_m);
00315       write(bin, param.blk_r);
00316     }
00317 
00318     //! BaryonElementalOperator reader
00319     void read(XMLReader& xml, const std::string& path, KeyBaryonElementalOperator_t& param)
00320     {
00321       XMLReader paramtop(xml, path);
00322     
00323       read(paramtop, "t_slice", param.t_slice);
00324       read(paramtop, "displacement_length", param.displacement_length);
00325       read(paramtop, "left", param.left);
00326       read(paramtop, "middle", param.middle);
00327       read(paramtop, "right", param.right);
00328       read(paramtop, "mom", param.mom);
00329       read(paramtop, "blk_l", param.blk_l);
00330       read(paramtop, "blk_m", param.blk_m);
00331       read(paramtop, "blk_r", param.blk_r);
00332     }
00333 
00334     //! BaryonElementalOperator writer
00335     void write(XMLWriter& xml, const std::string& path, const KeyBaryonElementalOperator_t& param)
00336     {
00337       push(xml, path);
00338 
00339       write(xml, "t_slice", param.t_slice);
00340       write(xml, "displacement_length", param.displacement_length);
00341       write(xml, "left", param.left);
00342       write(xml, "middle", param.middle);
00343       write(xml, "right", param.right);
00344       write(xml, "mom", param.mom);
00345       write(xml, "blk_l", param.blk_l);
00346       write(xml, "blk_m", param.blk_m);
00347       write(xml, "blk_r", param.blk_r);
00348       pop(xml);
00349     }
00350 
00351 
00352     //----------------------------------------------------------------------------
00353     //! BaryonElementalOperator reader
00354     void read(BinaryReader& bin, ValBaryonElementalOperator_t& param)
00355     {
00356       read(bin, param.type_of_data);
00357 
00358       int n;
00359       read(bin, n);    // the size is always written, even if 0
00360       param.op.resize(n,n,n);
00361   
00362       for(int i=0; i < n; ++i)
00363       {
00364         for(int j=0; j < n; ++j)
00365         {
00366           for(int k=0; k < n; ++k)
00367           {
00368             read(bin, param.op(i,j,k));
00369           }
00370         }
00371       }
00372     }
00373 
00374     //! BaryonElementalOperator write
00375     void write(BinaryWriter& bin, const ValBaryonElementalOperator_t& param)
00376     {
00377       write(bin, param.type_of_data);
00378 
00379       int n = param.op.size1();  // all sizes the same
00380       write(bin, n);
00381       for(int i=0; i < n; ++i)
00382       {
00383         for(int j=0; j < n; ++j)
00384         {
00385           for(int k=0; k < n; ++k)
00386           {
00387             write(bin, param.op(i,j,k));
00388           }
00389         }
00390       }
00391     }
00392 
00393 
00394     //----------------------------------------------------------------------------
00395     //! Normalize just one displacement array
00396     multi1d<int> normDisp(const multi1d<int>& orig)
00397     {
00398       START_CODE();
00399 
00400       multi1d<int> disp;
00401       multi1d<int> empty; 
00402       multi1d<int> no_disp(1); no_disp[0] = 0;
00403 
00404       // NOTE: a no-displacement is recorded as a zero-length array
00405       // Convert a length one array with no displacement into a no-displacement array
00406       if (orig.size() == 1)
00407       {
00408         if (orig == no_disp)
00409           disp = empty;
00410         else
00411           disp = orig;
00412       }
00413       else
00414       {
00415         disp = orig;
00416       }
00417 
00418       END_CODE();
00419 
00420       return disp;
00421     } // void normDisp
00422 
00423 
00424     //----------------------------------------------------------------------------
00425     //! Make sure displacements are something sensible
00426     multi1d<Params::Param_t::Displacement_t> 
00427     normalizeDisplacements(const multi1d<Params::Param_t::Displacement_t>& orig_list)
00428     {
00429       START_CODE();
00430 
00431       multi1d<Params::Param_t::Displacement_t> displacement_list(orig_list.size());
00432 
00433       // Loop over displacements
00434       for(int n=0; n < orig_list.size(); ++n)
00435       {
00436         const Params::Param_t::Displacement_t& o = orig_list[n];
00437         Params::Param_t::Displacement_t&       d = displacement_list[n];
00438 
00439         d.left   = normDisp(o.left);
00440         d.middle = normDisp(o.middle);
00441         d.right  = normDisp(o.right);
00442 
00443 //      QDPIO::cout << "disp[" << n << "]="
00444 //                  << "  left= " << d.left
00445 //                  << "  middle= " << d.middle
00446 //                  << "  right= " << d.right
00447 //                  << endl;
00448       }
00449 
00450       END_CODE();
00451 
00452       return displacement_list;
00453     } // void normalizeDisplacements
00454 
00455 
00456     //-------------------------------------------------------------------------------
00457     // Function call
00458     void 
00459     InlineMeas::operator()(unsigned long update_no,
00460                            XMLWriter& xml_out) 
00461     {
00462       // If xml file not empty, then use alternate
00463       if (params.xml_file != "")
00464       {
00465         string xml_file = makeXMLFileName(params.xml_file, update_no);
00466 
00467         push(xml_out, "BaryonBlockMatElem");
00468         write(xml_out, "update_no", update_no);
00469         write(xml_out, "xml_file", xml_file);
00470         pop(xml_out);
00471 
00472         XMLFileWriter xml(xml_file);
00473         func(update_no, xml);
00474       }
00475       else
00476       {
00477         func(update_no, xml_out);
00478       }
00479     }
00480 
00481 
00482     // Function call
00483     void 
00484     InlineMeas::func(unsigned long update_no,
00485                      XMLWriter& xml_out) 
00486     {
00487       START_CODE();
00488       if ( Nc != 3 ){    /* Code is specific to Ns=4 and Nc=3. */
00489         QDPIO::cerr<<"inline_baryon_block_matelem_w code only works for Nc=3 and Ns=4\n";
00490         QDP_abort(111) ;
00491       }
00492 #if QDP_NC == 3
00493 
00494 
00495       StopWatch snoop;
00496       snoop.reset();
00497       snoop.start();
00498 
00499       
00500       StopWatch swiss;
00501                         
00502       // Test and grab a reference to the gauge field
00503       XMLBufferWriter gauge_xml;
00504       try
00505       {
00506         TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
00507         TheNamedObjMap::Instance().get(params.named_obj.gauge_id).getRecordXML(gauge_xml);
00508 
00509         TheNamedObjMap::Instance().getData< SubsetVectors<LatticeColorVector> >(params.named_obj.colorvec_id).getEvectors();
00510       }
00511       catch( std::bad_cast ) 
00512       {
00513         QDPIO::cerr << name << ": caught dynamic cast error" << endl;
00514         QDP_abort(1);
00515       }
00516       catch (const string& e) 
00517       {
00518         QDPIO::cerr << name << ": map call failed: " << e << endl;
00519         QDP_abort(1);
00520       }
00521       const multi1d<LatticeColorMatrix>& u = 
00522         TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
00523 
00524       const SubsetVectors<LatticeColorVector>& eigen_source = 
00525         TheNamedObjMap::Instance().getData< SubsetVectors<LatticeColorVector> >(params.named_obj.colorvec_id);
00526 
00527       push(xml_out, "BaryonBlockMatElem");
00528       write(xml_out, "update_no", update_no);
00529 
00530       QDPIO::cout << name << ": Baryon color-vector matrix element" << endl;
00531 
00532       proginfo(xml_out);    // Print out basic program info
00533 
00534       // Write out the input
00535       params.writeXML(xml_out, "Input");
00536 
00537       // Write out the config info
00538       write(xml_out, "Config_info", gauge_xml);
00539 
00540       push(xml_out, "Output_version");
00541       write(xml_out, "out_version", 1);
00542       pop(xml_out);
00543 
00544       //First calculate some gauge invariant observables just for info.
00545       //This is really cheap.
00546       MesPlq(xml_out, "Observables", u);
00547 
00548       //
00549       // Initialize the slow Fourier transform phases
00550       //
00551       SftMom phases(params.param.mom2_max, false, params.param.decay_dir);
00552 
00553       //
00554       // Smear the gauge field if needed
00555       //
00556       multi1d<LatticeColorMatrix> u_smr = u;
00557 
00558       try
00559       {
00560         std::istringstream  xml_l(params.param.link_smearing.xml);
00561         XMLReader  linktop(xml_l);
00562         QDPIO::cout << "Link smearing type = " << params.param.link_smearing.id << endl;
00563         
00564         
00565         Handle< LinkSmearing >
00566           linkSmearing(TheLinkSmearingFactory::Instance().createObject(params.param.link_smearing.id,
00567                                                                        linktop, 
00568                                                                        params.param.link_smearing.path));
00569 
00570         (*linkSmearing)(u_smr);
00571       }
00572       catch(const std::string& e) 
00573       {
00574         QDPIO::cerr << name << ": Caught Exception link smearing: " << e << endl;
00575         QDP_abort(1);
00576       }
00577 
00578       MesPlq(xml_out, "Smeared_Observables", u_smr);
00579 
00580       //
00581       // Make sure displacements are something sensible
00582       //
00583       QDPIO::cout << "Normalize displacement lengths" << endl;
00584       multi1d<Params::Param_t::Displacement_t> displacement_list(normalizeDisplacements(params.param.displacement_list));
00585 
00586       //
00587       // The object holding the displaced color vector maps  
00588       //
00589       DispColorVectorMap smrd_disp_vecs(false,
00590                                         params.param.displacement_length,
00591                                         u_smr,
00592                                         eigen_source.getEvectors());
00593 
00594       //
00595       // DB storage
00596       //
00597       BinaryStoreDB< SerialDBKey<KeyBaryonElementalOperator_t>, SerialDBData<ValBaryonElementalOperator_t> > 
00598         qdp_db;
00599 
00600       // Open the file, and write the meta-data and the binary for this operator
00601       {
00602         XMLBufferWriter file_xml;
00603 
00604         push(file_xml, "DBMetaData");
00605         write(file_xml, "id", string("blockBaryonElemOp"));
00606         write(file_xml, "lattSize", QDP::Layout::lattSize());
00607         write(file_xml, "blockSize", params.param.block_size);
00608         write(file_xml, "decay_dir", params.param.decay_dir);
00609         write(file_xml, "Weights", eigen_source.getEvalues());
00610         write(file_xml, "Params", params.param);
00611         write(file_xml, "Config_info", gauge_xml);
00612         write(file_xml, "Op_Info",displacement_list);
00613         pop(file_xml);
00614 
00615         std::string file_str(file_xml.str());
00616         qdp_db.setMaxUserInfoLen(file_str.size());
00617 
00618         qdp_db.open(params.named_obj.baryon_op_file, O_RDWR | O_CREAT, 0664);
00619 
00620         qdp_db.insertUserdata(file_str);
00621       }
00622 
00623       //
00624       // Baryon operators
00625       //
00626       // The creation and annihilation operators are the same without the
00627       // spin matrices.
00628       //
00629       QDPIO::cout << "Building baryon operators" << endl;
00630 
00631       push(xml_out, "ElementalOps");
00632 
00633       // Loop over all time slices for the source. This is the same 
00634       // as the subsets for  phases
00635 
00636       //Make the block Set                                                       
00637       Set blocks;
00638       blocks.make(BlockFunc(params.param.decay_dir, params.param.block_size));
00639       
00640       QDPIO::cout<<"Number of Blocks: "<<blocks.numSubsets()<<endl;
00641       // Loop over each operator 
00642       for(int l=0; l < displacement_list.size(); ++l)
00643       {
00644         QDPIO::cout << "Elemental operator: op = " << l << endl;
00645 
00646         QDPIO::cout << "displacement: " << displacement_list[l] << endl;
00647 
00648         // Build the operator
00649         swiss.reset();
00650         swiss.start();
00651         
00652         multi1d<DisplacedBlock> dblk(3);
00653         for(int blk_left(0); blk_left < blocks.numSubsets(); blk_left++)
00654         {
00655           //QDPIO::cout<<"blk_left : "<<blk_left<<endl;
00656           dblk[0].blk  = blk_left;
00657           dblk[0].disp = displacement_list[l].left;
00658 
00659           for(int blk_middle(0); blk_middle < blocks.numSubsets(); blk_middle++)
00660           {
00661             dblk[1].blk  = blk_middle;
00662             dblk[1].disp = displacement_list[l].middle;
00663 
00664             if (blocks_couple(dblk, blocks, params.param.displacement_length, 2))
00665             {
00666               for(int blk_right(0); blk_right < blocks.numSubsets(); blk_right++)
00667               {
00668                 dblk[2].blk  = blk_right;
00669                 dblk[2].disp = displacement_list[l].right;
00670 
00671                 if (blocks_couple(dblk, blocks, params.param.displacement_length))
00672                 {
00673                   QDPIO::cout << "Doing block: " << blk_left << " " << blk_middle << " " << blk_right << endl;
00674 
00675                   // Big loop over the momentum projection
00676                   for(int mom_num = 0; mom_num < phases.numMom(); ++mom_num) 
00677                   {
00678                     // The keys for the displacements for this particular elemental operator
00679                     // Invert the time - make it an independent key
00680                     multi1d<KeyValBaryonElementalOperator_t> buf(phases.numSubsets());
00681                     for(int t=0; t < phases.numSubsets(); ++t)
00682                     {
00683                       buf[t].key.key().t_slice       = t;
00684                       buf[t].key.key().displacement_length = params.param.displacement_length;
00685                       buf[t].key.key().left          = displacement_list[l].left;
00686                       buf[t].key.key().middle        = displacement_list[l].middle;
00687                       buf[t].key.key().right         = displacement_list[l].right;
00688                       buf[t].key.key().mom           = phases.numToMom(mom_num);
00689                       buf[t].val.data().op.resize(params.param.num_vecs,params.param.num_vecs,params.param.num_vecs);
00690                       buf[t].key.key().blk_l         = blk_left;
00691                       buf[t].key.key().blk_m         = blk_middle;
00692                       buf[t].key.key().blk_r         = blk_right;
00693                           
00694                       // Build in some optimizations. 
00695                       // At this very moment, optimizations turned off
00696                       buf[t].val.data().type_of_data = COLORVEC_MATELEM_TYPE_GENERIC;
00697                     }
00698                       
00699                       
00700                     // The keys for the spin and displacements for this particular elemental operator
00701                     multi1d<KeyDispColorVector_t> keyDispColorVector(3);
00702                       
00703                     // Can displace each colorvector
00704                     keyDispColorVector[0].displacement = displacement_list[l].left;
00705                     keyDispColorVector[1].displacement = displacement_list[l].middle;
00706                     keyDispColorVector[2].displacement = displacement_list[l].right;
00707                     for(int i = 0; i <  params.param.num_vecs; ++i)
00708                     {
00709                       //QDPIO::cout<<"left: "<<i<<endl;
00710                       keyDispColorVector[0].colvec = i;
00711                       LatticeColorVector q_left = zero;
00712                       q_left[blocks[blk_left]] = smrd_disp_vecs.getDispVector(keyDispColorVector[0]);
00713                           
00714                       for(int j = 0; j < params.param.num_vecs; ++j)
00715                       {
00716                         //QDPIO::cout<<"middle: "<<j<<endl;
00717                         keyDispColorVector[1].colvec = j;
00718                         LatticeColorVector q_middle = zero;
00719                         q_middle[blocks[blk_middle]] = smrd_disp_vecs.getDispVector(keyDispColorVector[1]);
00720 
00721                         for(int k = 0; k < params.param.num_vecs; ++k)
00722                         {
00723                           //QDPIO::cout<<"right: "<<k<<endl;
00724                           keyDispColorVector[2].colvec = k;
00725                           LatticeColorVector q_right = zero;
00726                           q_right[blocks[blk_right]] = smrd_disp_vecs.getDispVector(keyDispColorVector[2]);
00727                                   
00728                           // Contract over color indices
00729                           // Do the relevant quark contraction
00730                           // Slow fourier-transform
00731                           LatticeComplex lop = colorContract(q_left,q_middle,q_right);
00732 
00733                           // Slow fourier-transform
00734                           multi1d<ComplexD> op_sum = sumMulti(phases[mom_num] * lop, phases.getSet());
00735                                   
00736                           for(int t=0; t < op_sum.size(); ++t)
00737                           {
00738                             buf[t].val.data().op(i,j,k) = op_sum[t];
00739                           }
00740                         } // end for k
00741                       } // end for j
00742                     } // end for i
00743                       
00744                     QDPIO::cout << "insert: mom_num= " << mom_num << " displacement num= " << l << endl; 
00745                     for(int t=0; t < phases.numSubsets(); ++t)
00746                     {
00747                       qdp_db.insert(buf[t].key, buf[t].val);
00748                     }
00749                   } // mom_num
00750                 } // if blocks couple
00751               }// right block loop
00752             } // if blocks_couple
00753           }// middle block loop
00754         }// left block loop
00755         
00756         swiss.stop();
00757         
00758         QDPIO::cout << "Baryon operator= " << l 
00759                     << "  time= "
00760                     << swiss.getTimeInSeconds() 
00761                     << " secs" << endl;
00762 
00763       } // for l
00764 
00765       pop(xml_out); // ElementalOps
00766 
00767       QDPIO::cout << "Baryon Operator written:"
00768                   << "  time= " << swiss.getTimeInSeconds() << " secs" << endl;
00769 
00770       // Close the namelist output file XMLDAT
00771       pop(xml_out);     // BaryonBlockMatElemtor
00772 
00773       snoop.stop();
00774       QDPIO::cout << name << ": total time = " 
00775                   << snoop.getTimeInSeconds() 
00776                   << " secs" << endl;
00777 
00778       QDPIO::cout << name << ": ran successfully" << endl;
00779 
00780 #endif
00781       END_CODE();
00782     } // func
00783   } // namespace InlineBaryonBlockMatElemEnv
00784 
00785   /*! @} */  // end of group hadron
00786 
00787 } // namespace Chroma
00788 
00789 
00790 

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