/** Returns a human-readable string representing this StringMatcherQueue, for easier debugging */ String StringMatcherQueue :: ToString() const { String ret; for (uint32 i=0; i<_queue.GetNumItems(); i++) { if (ret.HasChars()) ret += ' '; const StringMatcherRef & smr = _queue[i]; if (smr()) ret += smr()->ToString(); else ret += "(null)"; } return ret; }
int main(int argc, char** argv) { if (argc !=8 ) { cerr << "Usage: querysnap [configuration file][table Prefix] [graph id] [attrName] [edgeType] [k: resolution] [file prefix]\n"; exit(-1); } Config cf; cf.readFile(argv[1]); // cf.printConfig(); string path=string(argv[7]); if(path[path.size()-1]!='/') path=path+"/"; PGDB* db=new PGDB((char*)cf.dbname.c_str(), (char*)cf.dbuser.c_str(), (char*)cf.dbpwd.c_str()); string tablePrefix=string(argv[2]); int g=atoi(argv[3]); string attrname=string(argv[4]); string edgetype=string(argv[5]); ////////////////////////////////////// Summarizer smr(db); smr.setGraph(tablePrefix, g, attrname, edgetype); debug(33, "set graph succeed\n"); //topdown approach int k=atoi(argv[6]); if(k<=0) { cerr<<"Error: in valid k value (k>0): "<<k<<endl; exit(-1); } cout<<"-- Resolution: "<<k<<endl; MicroTimer timer; timer.reset(); smr.kSNAP(k); debug(33, "ksnap succeed\n"); char filename[200]; sprintf(filename, "%s%s_summary_%d.gdf", path.c_str(), tablePrefix.c_str(), k); cout<<" Summary: "<<filename<<endl; cout<<"-- Execution Time (s): "<<fixed<<setprecision(2)<<timer.stop_seconds()<<endl; ofstream of(filename); if(!of.is_open()) { cout<<"Error: Can not open file "<<filename<<endl; exit(-1); } writeSummaryGDFFormat(of, smr.colorArr, attrname, 's', Color::attrValues, edgetype); of.close(); delete db; return 0; }
//------------------------------------------------------------------ // //------------------------------------------------------------------ void AlgNuc3pt::run() { char *fname = "run()"; VRB.Func(cname,fname); if( Nuc3pt_arg->DoHalfFermion == 2 && Nuc3pt_arg->DoConserved == 1 ) { ERR.General(cname,fname,"DoConserved should be 2 when DoHalfFermion = 2!!!\n"); } // Always do point sink... Nuc2pt Nuc_c5(NUC_G5C,POINT) ; // do a few mesons for kicks Meson pion; pion.setGamma(-5); Meson vector[3]; vector[0].setGamma(0); vector[1].setGamma(1); vector[2].setGamma(2); char *MesonSrcTag ; switch (Nuc3pt_arg->src_type){ case POINT: MesonSrcTag = "POINT" ; break; case BOX: MesonSrcTag = "GFBOX" ; break; case GAUSS_GAUGE_INV: MesonSrcTag = "GSmear" ; break; default: // It should never get here! MesonSrcTag = "" ;// make GCC happy! ERR.General(cname,fname,"OOPS!!!\n"); break ; } pion.setSrc(MesonSrcTag); vector[0].setSrc(MesonSrcTag); vector[1].setSrc(MesonSrcTag); vector[2].setSrc(MesonSrcTag); int ZeroMom[3] ; ZeroMom[0]=ZeroMom[1]=ZeroMom[2]=0 ; ProjectType ptype[4] ; ptype[0] = PPAR_5X ; ptype[1] = PPAR_5Y ; ptype[2] = PPAR_5Z ; ptype[3] = PPAR_5 ; OpenFile(); Fprintf(fp,"List of momenta:\n"); int Nmom(56) ; ThreeMom sink_mom[56] ; int count(0); for(int p1=-2;p1<3;p1++) for(int p2=-2;p2<3;p2++) for(int p3=-2;p3<3;p3++) if((p1*p1+p2*p2+p3*p3)<=Nuc3pt_arg->MaxMom2) if((p1*p1+p2*p2+p3*p3)!=0)// eliminate the p=0 { Fprintf(fp,"\t\t\t%i: %i %i %i\n",count,p1,p2,p3); sink_mom[count] = ThreeMom(p1,p2,p3); count++ ; } CloseFile(); if(count>56) ERR.General(cname,fname,"No of momenta > 56\n"); //set the number of momenta Nmom=count ; // non-zero momentum give bad signal with BOX sources... // do not ever do it!! if( Nuc3pt_arg->src_type == BOX && (Nuc3pt_arg->BoxEnd - Nuc3pt_arg->BoxStart) != GJP.Xnodes()*GJP.XnodeSites()-1) Nmom=0 ; Float qmass(Nuc3pt_arg->Mass(0)) ; // Loop over source times OpenFile(); Fprintf(fp,"Doing quark Mass: %g\n", qmass); Fprintf(fp,"Doing %d sources inc= %d\n", Nuc3pt_arg->num_src, Nuc3pt_arg->source_inc); CloseFile(); // start: ts=t_source, then increment by "source_inc" int ts=Nuc3pt_arg->t_source; int mt[5]; if ( Nuc3pt_arg->num_mult > 1) ts=Nuc3pt_arg->mt[0]; // use the t_source, source_inc counter if not doing MultGauss. -MFL for(int i_source=0; i_source < Nuc3pt_arg->num_src; i_source++) { int t_sink = (ts + Nuc3pt_arg->t_sink)%(GJP.Tnodes()*GJP.TnodeSites()); OpenFile(); Fprintf(fp,"Doing source/sink time slices: %d %d\n", ts, t_sink); CloseFile(); // First calculate the needed two point functions Nuc_c5.Zero() ; pion.Zero() ; vector[0].Zero() ; vector[1].Zero() ; vector[2].Zero() ; char out_prop[200]; // If we don't do the coherent sink, we only allocate 1 propagator // hence we reuse the memory for the propagator for different source locations. // Otherwise we need to have all the propagators present at the same time // -- MFL int n; if (Nuc3pt_arg->num_src == num_qprop) n = i_source; else n = 0; GetThePropagator(n, ts, qmass); Nuc_c5.calcNucleon(*q_prop[n]) ; pion.setMass(qmass,qmass) ; pion.calcMeson(*q_prop[n],*q_prop[n]) ; vector[0].setMass(qmass,qmass) ; vector[0].calcMeson(*q_prop[n],*q_prop[n]) ; vector[1].setMass(qmass,qmass) ; vector[1].calcMeson(*q_prop[n],*q_prop[n]) ; vector[2].setMass(qmass,qmass) ; vector[2].calcMeson(*q_prop[n],*q_prop[n]) ; // Print out 2pt function results //---------------------------------------------------------------- OpenFile(); Nuc_c5.Print(fp) ; pion.Print(fp) ; vector[0].Print(fp) ; vector[1].Print(fp) ; vector[2].Print(fp) ; CloseFile(); //Do the projections needed for disconnected Ga for(int p(0);p<4;p++) { Nuc2pt Nuc_c5_p(NUC_G5C,POINT,ptype[p]) ; // Nuc_c5_p.Zero(); if(Nuc3pt_arg->DoGa1Proj||(p>2)) { Nuc_c5_p.calcNucleon(*q_prop[n]) ; OpenFile(); Nuc_c5_p.Print(fp) ; CloseFile(); } } //do some non-zero momenta { Nuc2pt Nuc_c5_p(NUC_G5C,POINT,PPAR_5) ; for(int m(0);m<Nmom;m++) { Nuc_c5.Zero() ; Nuc_c5.calcMomNucleon(*q_prop[n],sink_mom[m]) ; // Print out 2pt function results //---------------------------------------------------------------- OpenFile(); Nuc_c5.Print(fp) ; CloseFile(); // Calculate the smeared smeared momentum two point function // to extract alpha for NEDM reweighting Nuc_c5_p.Zero() ; Nuc_c5_p.calcMomNucleon(*q_prop[n],sink_mom[m]) ; // Print out 2pt function result //---------------------------------------------------------------- OpenFile(); Nuc_c5_p.Print(fp) ; CloseFile(); }// End momentum } //Do the smeared sink stuff if((Nuc3pt_arg->src_type==GAUSS_GAUGE_INV)&&(Nuc3pt_arg->DoSS2ptF)){ Nuc2pt Nuc_c5_ss(NUC_G5C,GAUSS_GAUGE_INV) ; QPropWGaussSrc smr(*q_prop[n]) ; QPropWGaussArg gauss_arg = q_prop[n]->GaussArg(); smr.GaussSmearSinkProp(gauss_arg); // First calculate the needed two point functions Nuc_c5_ss.Zero() ; Nuc_c5_ss.calcNucleon(smr) ; pion.Zero() ; pion.calcMeson(smr,smr) ; // Print out 2pt function results //---------------------------------------------------------------- OpenFile(); Nuc_c5_ss.Print(fp) ; pion.Print(fp) ; CloseFile(); //Do the projections needed for disconnected Ga for(int p(0);p<4;p++) { Nuc2pt Nuc_c5_ss_p(NUC_G5C,GAUSS_GAUGE_INV,ptype[p]) ; if(Nuc3pt_arg->DoGa1Proj||(p>2)){ Nuc_c5_ss_p.calcNucleon(smr) ; OpenFile(); Nuc_c5_ss_p.Print(fp) ; CloseFile(); } } //do some non-zero momenta { Nuc2pt Nuc_c5_ss_p(NUC_G5C,GAUSS_GAUGE_INV,PPAR_5) ; for(int m(0);m<Nmom;m++) { Nuc_c5_ss.Zero() ; Nuc_c5_ss.calcMomNucleon(smr,sink_mom[m]) ; // Print out 2pt function results //---------------------------------------------------------------- OpenFile(); Nuc_c5_ss.Print(fp) ; CloseFile(); // Calculate the smeared smeared momentum two point function // to extract alpha for NEDM reweighting Nuc_c5_ss_p.Zero() ; Nuc_c5_ss_p.calcMomNucleon(smr,sink_mom[m]) ; // Print out 2pt function results //---------------------------------------------------------------- OpenFile(); Nuc_c5_ss_p.Print(fp) ; CloseFile(); }// End momentum if(Nuc3pt_arg->DoHalfFermion == 2) { OpenFile(); Fprintf(fp,"DoHalfFermion=%d non-rel nucleon 2-pt\n",Nuc3pt_arg->DoHalfFermion); CloseFile(); q_prop[n]->NonRelProp( 1 ); { Nuc2pt Nuc_c5_p_nr(NUC_G5C,POINT) ; Nuc_c5_p_nr.Zero() ; Nuc_c5_p_nr.calcNucleon(*q_prop[n]) ; OpenFile(); Nuc_c5_p_nr.Print(fp) ; CloseFile(); for(int m(0);m<Nmom;m++) { Nuc_c5_p_nr.Zero() ; Nuc_c5_p_nr.calcMomNucleon(*q_prop[n],sink_mom[m]) ; OpenFile(); Nuc_c5_p_nr.Print(fp); CloseFile(); } } smr.NonRelProp( 0 ); int dohalf = Nuc3pt_arg->DoHalfFermion; // First calculate the needed two point functions { Nuc2pt Nuc_c5_g_nr(NUC_G5C,GAUSS_GAUGE_INV) ; Nuc_c5_g_nr.Zero() ; Nuc_c5_g_nr.calcNucleon(smr) ; // Print out 2pt function results //---------------------------------------------------------------- OpenFile(); Nuc_c5_g_nr.Print(fp) ; CloseFile(); //do some non-zero momenta for(int m(0);m<Nmom;m++) { Nuc_c5_g_nr.Zero() ; Nuc_c5_g_nr.calcMomNucleon(smr,sink_mom[m]) ; // Print out 2pt function results //---------------------------------------------------------------- OpenFile(); Nuc_c5_g_nr.Print(fp) ; CloseFile(); }// End momentum } } // DoHalfF = 2 // } // End loop over qprop // Finally, smear the sink at time t_sink for 3-pt functions (below) for(int nt=0; nt<Nuc3pt_arg->num_mult; nt++){ // Multi Gauss t_sink set mt[nt]=Nuc3pt_arg->mt[nt]; //save Nuc3pt_arg->mt[nt]+=Nuc3pt_arg->t_sink; // locations of the proton sinks Nuc3pt_arg->mt[nt]=Nuc3pt_arg->mt[nt]%(GJP.Tnodes()*GJP.TnodeSites()); q_prop[n]->GaussSmearSinkProp(Nuc3pt_arg->mt[nt],q_prop[n]->GaussArg()); } } //end smeared sink } //Now do the 3pt functions // If doing coherent sinks, don't calculate the 3pt functions until all the // forward propagators have been calculated. --MFL int do_seq = 0; // int t_sink; if(Nuc3pt_arg->calc_seqQ != MULT_SEQ && Nuc3pt_arg->calc_seqQ != WRITE_MULT_SEQ && Nuc3pt_arg->calc_seqQ != READ_MULT_SEQ) { do_seq = 1; t_sink = ts + Nuc3pt_arg->t_sink; } // once all the forward propagators have been calculated, // do the sequential propagaotrs. --MFL else if (i_source == num_qprop-1) { do_seq = 1; t_sink = Nuc3pt_arg->t_source + Nuc3pt_arg->t_sink; } if(Nuc3pt_arg->DoUnPolarized && do_seq) { // for conserved vector currents Gamma Gt(T); Nuc3ptCons VectCurr(Gt); Nuc3ptCons *VectCurrp[4]; if(Nuc3pt_arg->DoConserved) { for (int i(X);i<4;i++){ DIR d = DIR(i) ; Gamma G(d); VectCurrp[i] = new Nuc3ptCons(Nmom,G) ; } } OpenFile(); Fprintf(fp,"UnPolarized Zero mom.\n"); CloseFile(); //first do the zero momentum un-polarized stuff //up-quark GetTheSeqPropagator(t_sink,qmass, PROT_U_SEQ,ZeroMom,PPAR); //down-quark GetTheSeqPropagator(t_sink,qmass, PROT_D_SEQ,ZeroMom,PPAR); calc_Scalar(); //needed for the sigma term calc_Vector(); //Vector current calc_X_q_b(); //<x>_q (b) does not need non-zero momentum for(int i(0) ; i<Nmom ; i++) calc_Vector(sink_mom[i]); //conserved current if(Nuc3pt_arg->DoConserved) { if(GJP.Snodes()==2) u_s_prop->SwapQPropLs(); for ( int nt = 0; nt < num_qprop; nt++ ) { VectCurr.Calc3pt(*u_s_prop,*q_prop[nt]); for (int i(X);i<4;i++) VectCurrp[i]->Calc3pt(*u_s_prop,*q_prop[nt],Nmom,sink_mom); } char* dummy; u_s_prop->RestoreOrgProp(dummy,1); u_s_prop->DeleteQPropLs(); if(GJP.Snodes()==2) d_s_prop->SwapQPropLs(); for ( int nt = 0; nt < num_qprop; nt++ ) { VectCurr.Calc3pt(*d_s_prop,*q_prop[nt]); for (int i(X);i<4;i++) VectCurrp[i]->Calc3pt(*d_s_prop,*q_prop[nt],Nmom,sink_mom); } d_s_prop->RestoreOrgProp(dummy,1); d_s_prop->DeleteQPropLs(); OpenFile(); Fprintf(fp,"UnPolarized Zero mom Conserved Vector\n"); VectCurr.Print(fp) ; for (int i(X);i<4;i++) VectCurrp[i]->Print(fp,Nmom,sink_mom) ; CloseFile(); } if(Nuc3pt_arg->DoConserved) { for (int i(X);i<4;i++) delete VectCurrp[i]; } } if(Nuc3pt_arg->DoUnPolarizedMom && do_seq) { OpenFile(); Fprintf(fp,"UnPolarized mom.\n"); CloseFile(); int UnitMom[3]; UnitMom[1]=1 ; // check the conventions UnitMom[0]=UnitMom[2]=0 ; //up-quark GetTheSeqPropagator(t_sink,qmass, PROT_U_SEQ,UnitMom,PPAR); //down-quark GetTheSeqPropagator(t_sink,qmass, PROT_D_SEQ,UnitMom,PPAR); calc_Scalar(); //needed for the sigma term calc_Vector(); //Vector current calc_X_q_b(); //<x>_q (b) does not need non-zero momentum for(int i(0) ; i<Nmom ; i++) calc_Vector(sink_mom[i]); calc_X_q_a(); //<x>_q (a) needs non-zero momentum calc_X2_q(); //<x^2>_q needs non-zero momentum calc_X3_q(); //<x^3>_q needs non-zero momentum } // Polarized if(Nuc3pt_arg->DoPolarized && do_seq) { // for conserved axial and vector currents Gamma G5z(G5,Z); Nuc3ptCons AxialCurr(Complex(0.0,1.0),G5z); Nuc3ptCons *AxialCurrp[4]; Nuc3ptCons *VectCurrp[4]; if(Nuc3pt_arg->DoConserved) { for (int i(X);i<4;i++){ DIR d = DIR(i); Gamma G5d(G5,d); AxialCurrp[i] = new Nuc3ptCons(Nmom,Complex(0.0,1.0),G5d); d = DIR(i) ; Gamma G(d); VectCurrp[i] = new Nuc3ptCons(Nmom,G) ; } } OpenFile(); Fprintf(fp,"Polarized Zero mom.\n"); CloseFile(); // //up-quark GetTheSeqPropagator(t_sink,qmass, PROT_U_SEQ,ZeroMom,PPAR_5Z); //down-quark GetTheSeqPropagator(t_sink,qmass, PROT_D_SEQ,ZeroMom,PPAR_5Z); calc_Axial(); //Axial-Vector current i Gamma_5 Gamma_z calc_Tensor() ;//Tensor current i Gamma_5 Gamma_z Gamma_t calc_X_Dq_b() ; calc_d1() ; for(int i(0) ; i<Nmom ; i++){ calc_Vector(sink_mom[i]);//neutron EDM and mangetic moment calc_Axial(sink_mom[i]);//axial form factors calc_EnergyMomentum(sink_mom[i]) ; // proton spin calc_PScalar(sink_mom[i]);//pseudoscalar form factors } if(Nuc3pt_arg->DoConserved) { if(GJP.Snodes()==2) { u_s_prop->SwapQPropLs(); d_s_prop->SwapQPropLs(); } for ( int nt = 0; nt < num_qprop; nt++ ) { AxialCurr.Calc3pt(*u_s_prop,*q_prop[nt]); for(int i(X);i<4;i++){ AxialCurrp[i]->Calc3pt(*u_s_prop,*q_prop[nt],Nmom,sink_mom); VectCurrp[i]->Calc3pt(*u_s_prop,*q_prop[nt],Nmom,sink_mom); } AxialCurr.Calc3pt(*d_s_prop,*q_prop[nt]); for(int i(X);i<4;i++){ AxialCurrp[i]->Calc3pt(*d_s_prop,*q_prop[nt],Nmom,sink_mom); VectCurrp[i]->Calc3pt(*d_s_prop,*q_prop[nt],Nmom,sink_mom); } OpenFile(); Fprintf(fp,"Polarized Zero mom Conserved Axial and Vector\n"); AxialCurr.Print(fp) ; for (int i(X);i<4;i++) { VectCurrp[i]->Print(fp,Nmom,sink_mom) ; } for (int i(X);i<4;i++) { AxialCurrp[i]->Print(fp,Nmom,sink_mom) ; } CloseFile(); } char* dummy; u_s_prop->RestoreOrgProp(dummy,1); u_s_prop->DeleteQPropLs(); d_s_prop->RestoreOrgProp(dummy,1); d_s_prop->DeleteQPropLs(); } if(Nuc3pt_arg->DoConserved) { for(int i(X);i<4;i++) { delete AxialCurrp[i]; delete VectCurrp[i]; } } } if(Nuc3pt_arg->DoPolarizedMom && do_seq) { OpenFile(); Fprintf(fp,"Polarized with mom.\n"); CloseFile(); int UnitMom[3]; UnitMom[1]=1 ; // check the conventions UnitMom[0]=UnitMom[2]=0 ; //up-quark GetTheSeqPropagator(t_sink,qmass, PROT_U_SEQ,UnitMom,PPAR_5Z); //down-quark GetTheSeqPropagator(t_sink,qmass, PROT_D_SEQ,UnitMom,PPAR_5Z); for(int i(0) ; i<Nmom ; i++){ calc_Vector(sink_mom[i]);//neutron EDM and magnetic moment calc_Axial(sink_mom[i]);//axial form factors calc_EnergyMomentum(sink_mom[i]) ; // proton spin } calc_X_Dq_a() ; calc_X2_Dq() ; calc_X_dq() ; calc_d2() ; } if(Nuc3pt_arg->DoConserved) q_prop[n]->DeleteQPropLs(); ts+=Nuc3pt_arg->source_inc; for(int nt=0; nt<Nuc3pt_arg->num_mult; nt++){ Nuc3pt_arg->mt[nt]=mt[nt]; Nuc3pt_arg->mt[nt]+=Nuc3pt_arg->source_inc; } /* if(i_source==1){ // obsolete. commented out --MFL ts+=Nuc3pt_arg->mt[4]; for(int nt=0; nt<Nuc3pt_arg->num_mult; nt++){ Nuc3pt_arg->mt[nt]+=Nuc3pt_arg->mt[4]; } } */ } // end loop over source timeslices } // end run