Пример #1
0
t_qtrn	qtrn_external_prod(const t_qtrn *const a, const t_real s)
{
	t_qtrn	ans;

	ans.type = a->type;
	if (a->type == CARTHESIAN)
	{
		X(ans) = XP(a) * s;
		Y(ans) = YP(a) * s;
		Z(ans) = ZP(a) * s;
		W(ans) = WP(a) * s;
	}
	else if (a->type == CYLINDRICAL)
	{
		QR(ans) = QRP(a) * s;
		QTHETA(ans) = QTHETAP(a);
		Z(ans) = ZP(a) * s;
		W(ans) = WP(a) * s;
	}
	else
	{
		QRHO(ans) = QRHOP(a) * s;
		QTHETA(ans) = QTHETAP(a);
		QPHI(ans) = QPHIP(a);
		W(ans) = WP(a) * s;
	}
	return (ans);
}
Пример #2
0
TEST(SymbolTable, evaluateSimple) {
  CompileErrorList errors;
  SymbolGraph graph;
  graph.addNode(Symbol(ZP("Hi"), ZP("Bye")));
  auto eval = graph.evaluate();
  ASSERT_TRUE(eval.valid());
}
Пример #3
0
t_real	qtrn_get_norm(const t_qtrn *const q)
{
	if (q->type == CARTHESIAN)
		return (XP(q) * XP(q) + YP(q) * YP(q)
			+ ZP(q) * ZP(q) + WP(q) * WP(q));
	else if (q->type == CYLINDRICAL)
		return (ZP(q) * ZP(q) + QRP(q) * QRP(q));
	else
		return (QRHOP(q));
}
Пример #4
0
t_qtrn	qtrn_get_conj(const t_qtrn *const q)
{
	if (q->type == CARTHESIAN)
		return (NEW_QTRN(-XP(q), -YP(q), -ZP(q), WP(q)));
	else if (q->type == CYLINDRICAL)
		return ((t_qtrn){CYLINDRICAL, {{
			QRP(q), QTHETAP(q) + M_PI, -ZP(q), WP(q)}}});
	else
		return ((t_qtrn){SPHERICAL, {{
			QRHOP(q), QTHETAP(q) + M_PI, QPHIP(q) + M_PI, WP(q)}}});
}
Пример #5
0
TEST(SymbolTable, replaceSimple) {
  CompileErrorList errors;
  SymbolGraph graph;
  graph.addNode(Symbol(ZP("A"), ZP("B")));
  graph.addNode(Symbol(ZP("B"), ZP("C")));
  graph.addNode(Symbol(ZP("C"), ZP("D")));
  graph.addNode(Symbol(ZP("E"), ZP("C")));
  auto eval = graph.evaluate();
  ASSERT_TRUE(eval.valid());
  SymbolReplacer replacer(eval);
  auto result =
      replacer.replace(ZP("A+B+C+c=E-D+X-ABCDEFG-124*12B32#E"), errors);
  ASSERT_EQ(result.string(), "D+D+D+c=D-D+X-ABCDEFG-124*12B32#D");
}
Пример #6
0
void	cylin2spher(t_vec3t *v)
{
	const t_real		z = ZP(v);
	const t_real		r = RP(v);

	RHOP(v) = sqrt(z * z + r * r);
	PHIP(v) = atan2(r, z);
	v->type = SPHERICAL;
}
Пример #7
0
void	spher2cylin(t_vec3t *v)
{
	const t_real		rho = RHOP(v);
	const t_real		theta = THETAP(v);

	ZP(v) = cos(theta) * rho;
	RP(v) = sin(theta) * rho;
	v->type = CYLINDRICAL;
}
Пример #8
0
TEST(SymbolTable, simpleCycle) {
  CompileErrorList errors;
  SymbolGraph graph;
  graph.addNode(Symbol(ZP("A"), ZP("B")));
  graph.addNode(Symbol(ZP("B"), ZP("C")));
  graph.addNode(Symbol(ZP("C"), ZP("D")));
  graph.addNode(Symbol(ZP("D"), ZP("A")));
  auto eval = graph.evaluate();
  ASSERT_FALSE(eval.valid());
  ASSERT_FALSE(eval.sampleCycle().empty());
  ASSERT_EQ(eval.sampleCycle().size(), 4);
}
Пример #9
0
void	qtrn_conj(t_qtrn *const q)
{
	if (q->type == CARTHESIAN)
	{
		XP(q) *= -1;
		YP(q) *= -1;
		ZP(q) *= -1;
	}
	else if (q->type == CYLINDRICAL)
	{
		QTHETAP(q) += M_PI;
		ZP(q) *= -1;
	}
	else
	{
		QTHETAP(q) += M_PI;
		QPHIP(q) += M_PI;
	}
}
Пример #10
0
void	spher2carth(t_vec3t *v)
{
	const t_real		r = RHOP(v);
	const t_real		t = THETAP(v);
	const t_real		p = PHIP(v);

	XP(v) = r * sin(p) * cos(t);
	YP(v) = r * sin(p) * sin(t);
	ZP(v) = r * cos(p);
	v->type = CARTHESIAN;
}
Пример #11
0
void	carth2spher(t_vec3t *v)
{
	const t_real		x = XP(v);
	const t_real		y = YP(v);
	const t_real		z = ZP(v);

	RHOP(v) = sqrt(x * x + y * y + z * z);
	THETAP(v) = atan2(y, x);
	PHIP(v) = acos(z / RHOP(v));
	v->type = SPHERICAL;
}
Пример #12
0
void	qtrn_external_mult(t_qtrn *const a, const t_real s)
{
	if (a->type == CARTHESIAN)
	{
		XP(a) *= s;
		YP(a) *= s;
		ZP(a) *= s;
		WP(a) *= s;
	}
	else if (a->type == CYLINDRICAL)
	{
		QRP(a) *= s;
		ZP(a) *= s;
		WP(a) *= s;
	}
	else
	{
		QRHOP(a) *= s;
		WP(a) *= s;
	}
}
Пример #13
0
TEST(SymbolTable, simpleDoubleCycle) {
  CompileErrorList errors;
  SymbolGraph graph;
  graph.addNode(Symbol(ZP("a"), ZP("a+b")));
  graph.addNode(Symbol(ZP("b"), ZP("a")));
  graph.addNode(Symbol(ZP("c"), ZP("a")));
  auto eval = graph.evaluate();
  ASSERT_FALSE(eval.valid());
  ASSERT_FALSE(eval.sampleCycle().empty());
}
Пример #14
0
TEST(SymbolTable, doubleInsertion) {
  CompileErrorList errors;
  SymbolGraph graph;
  graph.addNode(Symbol(ZP("A"), ZP("B")));
  graph.addNode(Symbol(ZP("A"), ZP("C")));
  graph.addNode(Symbol(ZP("C"), ZP("D")));
  graph.addNode(Symbol(ZP("C"), ZP("D")));
  graph.addNode(Symbol(ZP("C"), ZP("D")));
  graph.addNode(Symbol(ZP("D"), ZP("A")));
  auto eval = graph.evaluate();
  ASSERT_FALSE(eval.valid());
  ASSERT_FALSE(eval.duplicates().empty());
  ASSERT_EQ(eval.duplicates().size(), 2);
}
Пример #15
0
	{ "TYA", 0, { IMP(0x98), -1 } },
	{ "TSX", 0, { IMP(0xBA), -1 } },
	{ "TXS", 0, { IMP(0x9A), -1 } },
	{ "DEX", 0, { IMP(0xCA), -1 } },
	{ "DEY", 0, { IMP(0x88), -1 } },
	{ "INX", 0, { IMP(0xE8), -1 } },
	{ "INY", 0, { IMP(0xC8), -1 } },
	{ "CLC", 0, { IMP(0x18), -1 } },
	{ "CLD", 0, { IMP(0xD8), -1 } },
	{ "CLI", 0, { IMP(0x58), -1 } },
	{ "CLV", 0, { IMP(0xB8), -1 } },
	{ "SEC", 0, { IMP(0x38), -1 } },
	{ "SED", 0, { IMP(0xF8), -1 } },
	{ "SEI", 0, { IMP(0x78), -1 } },
	{ "NOP", 0, { IMP(0xEA), -1 } },
	{ "ASL", 1, { IMP(0x0a), ZP(0x06), ZPX(0x16), ABS(0x0E), ABX(0x1E), -1 } },
	{ "DEC", 3, { ZP(0xc6), ZPX(0xd6), ABS(0xcE), ABX(0xdE), -1 } },
	{ "INC", 3, { ZP(0xe6), ZPX(0xf6), ABS(0xeE), ABX(0xfE), -1 } },
	{ "LSR", 3, { IMP(0x4a), ZP(0x46), ZPX(0x56), ABS(0x4E), ABX(0x5E), -1 } },
	{ "ROL", 3, { IMP(0x2a), ZP(0x26), ZPX(0x36), ABS(0x2E), ABX(0x3E), -1 } },
	{ "ROR", 3, { IMP(0x6a), ZP(0x66), ZPX(0x76), ABS(0x6E), ABX(0x7E), -1 } },
	{ "ADC", 1, { IMD(0x69), ZP(0x65), ZPX(0x75), ABS(0x6D), ABX(0x7d), ABY(0x79),
				  INX(0x61), INY(0x71), -1 } },
	{ "AND", 1, { IMD(0x29), ZP(0x25), ZPX(0x35), ABS(0x2D), ABX(0x3d), ABY(0x39),
				  INX(0x21), INY(0x31), -1 } },
	{ "BIT", 1, { ZP(0x24), ABS(0x2c), -1 } },
	{ "CMP", 1, { IMD(0xc9), ZP(0xc5), ZPX(0xd5), ABS(0xcD), ABX(0xdd), ABY(0xd9),
				  INX(0xc1), INY(0xd1), -1 } },
	{ "CPX", 1, { IMD(0xe0), ZP(0xe4), ABS(0xec), -1 } },
	{ "CPY", 1, { IMD(0xc0), ZP(0xc4), ABS(0xcc), -1 } },
	{ "EOR", 1, { IMD(0x49), ZP(0x45), ZPX(0x55), ABS(0x4D), ABX(0x5d), ABY(0x59),
Пример #16
0
TEST(SymbolTable, correctName) {
  CompileErrorList errors;
  SymbolGraph graph;
  graph.addNode(Symbol(ZP("a"), ZP("")));
  graph.addNode(Symbol(ZP("_"), ZP("")));
  graph.addNode(Symbol(ZP("hai"), ZP("")));
  graph.addNode(Symbol(ZP("_someVariable"), ZP("")));
  graph.addNode(Symbol(ZP("LONG"), ZP("")));
  graph.addNode(Symbol(ZP("VERY_LONG"), ZP("")));
  graph.addNode(Symbol(ZP("capslock"), ZP("")));
  auto eval = graph.evaluate();
  ASSERT_TRUE(eval.valid());
}
Пример #17
0
TEST(SymbolTable, recursiveReplace) {
  CompileErrorList errors;
  SymbolGraph graph;
  graph.addNode(Symbol(ZP("A"), ZP("(B C D 0)")));
  graph.addNode(Symbol(ZP("B"), ZP("(C C 1)")));
  graph.addNode(Symbol(ZP("C"), ZP("(D D D 2)")));
  graph.addNode(Symbol(ZP("D"), ZP("(E 3)")));
  graph.addNode(Symbol(ZP("E"), ZP("(X 4)")));
  graph.addNode(Symbol(ZP("F"), ZP("(A B C D E X 5)")));
  auto eval = graph.evaluate();
  ASSERT_TRUE(eval.valid());
  SymbolReplacer replacer(eval);
  auto result = replacer.replace(ZP("F ABCDEFG HIJKLMNOP A B F"), errors);
  ASSERT_EQ(result.string(),
            "((((((X 4) 3) ((X 4) 3) ((X 4) 3) 2) (((X 4) 3) ((X 4) 3) ((X 4) "
            "3) 2) 1) (((X 4) 3) ((X 4) 3) ((X 4) 3) 2) ((X 4) 3) 0) ((((X 4) "
            "3) ((X 4) 3) ((X 4) 3) 2) (((X 4) 3) ((X 4) 3) ((X 4) 3) 2) 1) "
            "(((X 4) 3) ((X 4) 3) ((X 4) 3) 2) ((X 4) 3) (X 4) X 5) ABCDEFG "
            "HIJKLMNOP (((((X 4) 3) ((X 4) 3) ((X 4) 3) 2) (((X 4) 3) ((X 4) "
            "3) ((X 4) 3) 2) 1) (((X 4) 3) ((X 4) 3) ((X 4) 3) 2) ((X 4) 3) 0) "
            "((((X 4) 3) ((X 4) 3) ((X 4) 3) 2) (((X 4) 3) ((X 4) 3) ((X 4) 3) "
            "2) 1) ((((((X 4) 3) ((X 4) 3) ((X 4) 3) 2) (((X 4) 3) ((X 4) 3) "
            "((X 4) 3) 2) 1) (((X 4) 3) ((X 4) 3) ((X 4) 3) 2) ((X 4) 3) 0) "
            "((((X 4) 3) ((X 4) 3) ((X 4) 3) 2) (((X 4) 3) ((X 4) 3) ((X 4) 3) "
            "2) 1) (((X 4) 3) ((X 4) 3) ((X 4) 3) 2) ((X 4) 3) (X 4) X 5)");
}
Пример #18
0
TEST(SymbolTable, lessSimpleCycle) {
  CompileErrorList errors;
  SymbolGraph graph;
  graph.addNode(Symbol(ZP("A"), ZP("A B C D E F G H I J K")));
  graph.addNode(Symbol(ZP("B"), ZP("B C D E F")));
  graph.addNode(Symbol(ZP("C"), ZP("D")));
  graph.addNode(Symbol(ZP("D"), ZP("E F G H J K")));
  graph.addNode(Symbol(ZP("E"), ZP("F G")));
  graph.addNode(Symbol(ZP("F"), ZP("G")));
  graph.addNode(Symbol(ZP("G"), ZP("B H J K")));
  graph.addNode(Symbol(ZP("H"), ZP("")));
  graph.addNode(Symbol(ZP("I"), ZP("J K")));
  graph.addNode(Symbol(ZP("J"), ZP("")));
  graph.addNode(Symbol(ZP("K"), ZP("A")));
  auto eval = graph.evaluate();
  ASSERT_FALSE(eval.valid());
  ASSERT_FALSE(eval.sampleCycle().empty());
}
Пример #19
0
void extr(jvec &ext_EP,jvec &ext_ED,jvec &ext_Q2,jvec &ext_fP,jvec &ext_fM,jvec &ext_f0,jvec &ext_fT,int il_sea,int il,int ic)
{
  ////////////////////////////////////////// R0 //////////////////////////////////////  

  jvec R0_corr;
  jack R0(njack);
  
  //load standing
  jvec ll0_st=load_3pts("V0",il,il,0,RE,ODD,1);
  jvec lc0_st=load_3pts("V0",ic,il,0,RE,ODD,1);
  jvec cc0_st=load_3pts("V0",ic,ic,0,RE,ODD,1);
  
  //build R0
  R0_corr=lc0_st*lc0_st.simmetric()/(cc0_st*ll0_st);
  
  //fit and plot
  R0=constant_fit(R0_corr,TH-tmax,tmax,combine("plots/R0_il_%d_ic_%d.xmg",il,ic).c_str());
  
  //////////////////////////////////////////// R2 ////////////////////////////////////
  
  jvec R2_corr[nth];
  jvec RT_corr[nth];
  jvec R2(nth,njack);
  jvec RT(nth,njack);
  
  ofstream out_R2(combine("plots/R2_il_%d_ic_%d.xmg",il,ic).c_str());
  ofstream out_RT(combine("plots/RT_il_%d_ic_%d.xmg",il,ic).c_str());
  jvec lcK_th[nth],lc0_th[nth],lcT_th[nth];
  for(int ith=0;ith<nth;ith++)
    {
      //load corrs
      lcK_th[ith]=load_3pts("VK",ic,il,ith,IM,EVN,-1)/(6*th_P[ith]);
      lc0_th[ith]=load_3pts("V0",ic,il,ith,RE,ODD,1);
      lcT_th[ith]=load_3pts("VTK",ic,il,ith,IM,ODD,1)/(6*th_P[ith]);
      
      //build ratios
      R2_corr[ith]=lcK_th[ith]/lc0_th[ith];
      RT_corr[ith]=lcT_th[ith]/lcK_th[ith];
      
      //fit
      R2[ith]=constant_fit(R2_corr[ith],tmin,tmax);
      RT[ith]=constant_fit(RT_corr[ith],tmin,tmax);
      
      //plot
      out_R2<<write_constant_fit_plot(R2_corr[ith],R2[ith],tmin,tmax);
      out_RT<<write_constant_fit_plot(RT_corr[ith],RT[ith],tmin,tmax);
    }
  
  ////////////////////////////////////////// R1 //////////////////////////////////////  
  
  jvec R1_corr[nth];
  jvec R1(nth,njack);

  ofstream out_P(combine("plots/out_P_il_%d_ic_%d.xmg",il,ic).c_str());
  out_P<<"@type xydy"<<endl;
  ofstream out_D(combine("plots/out_D_il_%d_ic_%d.xmg",il,ic).c_str());
  out_D<<"@type xydy"<<endl;
  ofstream out_R1(combine("plots/out_R1_il_%d_ic_%d.xmg",il,ic).c_str());
  out_R1<<"@type xydy"<<endl;
  
  //load Pi and D
  jvec P_corr[nth],D_corr[nth];
  jvec ED(nth,njack),EP(nth,njack);
  for(int ith=0;ith<nth;ith++)
    {
      //load moving pion
      P_corr[ith]=load_2pts("2pts_P5P5.dat",il_sea,il,ith);
      out_P<<"@type xydy"<<endl;
      EP[ith]=constant_fit(effective_mass(P_corr[ith]),tmin_P,TH,combine("plots/P_eff_mass_il_%d_ic_%d_ith_%d.xmg",
									 il,ic,ith).c_str());
      out_P<<write_constant_fit_plot(effective_mass(P_corr[ith]),EP[ith],tmin_P,TH);
      out_P<<"&"<<endl;
      
      //recompute EP and ED from standing one
      if(ith)
	{
	  ED[ith]=latt_en(ED[0],th_P[ith]);
	  EP[ith]=latt_en(EP[0],th_P[ith]);
	}

      //load moving D
      D_corr[ith]=load_2pts("2pts_P5P5.dat",il,ic,ith);
      out_D<<"@type xydy"<<endl;
      ED[ith]=constant_fit(effective_mass(D_corr[ith]),tmin_D,TH,combine("plots/D_eff_mass_il_%d_ic_%d_ith_%d.xmg",
									 il,ic,ith).c_str());
      out_D<<write_constant_fit_plot(effective_mass(D_corr[ith]),ED[ith],tmin_D,TH);
      out_D<<"&"<<endl;
      
      //build the ratio
      R1_corr[ith]=lc0_th[ith]/lc0_th[0];
      for(int t=0;t<TH;t++)
	{
	  int E_fit_reco_flag=1;

	  jack Dt(njack),Pt(njack);	  
	  if(E_fit_reco_flag==0)
	    {
	      Dt=D_corr[0][t]/D_corr[ith][t];
	      Pt=P_corr[0][TH-t]/P_corr[ith][TH-t];
	    }
	  else
	    {
	      jack ED_th=latt_en(ED[0],th_P[ith]),EP_th=latt_en(EP[0],th_P[ith]);
	      Dt=exp(-(ED[0]-ED_th)*t)*ED_th/ED[0];
	      Pt=exp(-(EP[0]-EP_th)*(TH-t))*EP_th/EP[0];
	    }
	  
	  R1_corr[ith][t]*=Dt*Pt;
	}
      
      //fit
      R1[ith]=constant_fit(R1_corr[ith],tmin,tmax);
      
      //plot
      out_R1<<write_constant_fit_plot(R1_corr[ith],R1[ith],tmin,tmax);
    }
  
  //////////////////////////////////////// solve the ratios //////////////////////////////
  
  //compute f0[q2max]
  jvec f0_r(nth,njack),fP_r(nth,njack),fT_r(nth,njack);
  f0_r[0]=sqrt(R0*4*ED[0]*EP[0])/(ED[0]+EP[0]);
  cout<<"f0_r[q2max]: "<<f0_r[0]<<endl;
  
  //compute QK and Q2
  double mom[nth];
  jvec PK(nth,njack),QK(nth,njack);
  jvec P0(nth,njack),Q0(nth,njack),Q2(nth,njack),P2(nth,njack);
  jvec P0_r(nth,njack),Q0_r(nth,njack),Q2_r(nth,njack),P2_r(nth,njack);
  for(int ith=0;ith<nth;ith++)
    {
      P0[ith]=ED[ith]+EP[ith]; //P=initial+final
      Q0[ith]=ED[ith]-EP[ith]; //Q=initial-final
      P0_r[ith]=latt_en(ED[0],th_P[ith])+latt_en(EP[0],th_P[ith]);
      Q0_r[ith]=latt_en(ED[0],th_P[ith])-latt_en(EP[0],th_P[ith]);

      //we are describing the process D->Pi
      mom[ith]=momentum(th_P[ith]);
      double P_D=-mom[ith];
      double P_Pi=mom[ith];
  
      PK[ith]=P_D+P_Pi;
      QK[ith]=P_D-P_Pi;
      
      P2[ith]=sqr(P0[ith])-3*sqr(PK[ith]);
      Q2[ith]=sqr(Q0[ith])-3*sqr(QK[ith]);
      
      //reconstruct Q2
      P2_r[ith]=sqr(P0_r[ith])-3*sqr(PK[ith]);
      Q2_r[ith]=sqr(Q0_r[ith])-3*sqr(QK[ith]);
    }

  //checking Pion dispertion relation
  ofstream out_disp_P(combine("plots/Pion_disp_rel_il_%d_ic_%d.xmg",il,ic).c_str());
  out_disp_P<<"@type xydy"<<endl;
  for(int ith=0;ith<nth;ith++) out_disp_P<<3*sqr(mom[ith])<<" "<<sqr(EP[ith])<<endl;
  out_disp_P<<"&"<<endl;
  for(int ith=0;ith<nth;ith++) out_disp_P<<3*sqr(mom[ith])<<" "<<sqr(cont_en(EP[0],th_P[ith]))<<endl;
  out_disp_P<<"&"<<endl;
  for(int ith=0;ith<nth;ith++) out_disp_P<<3*sqr(mom[ith])<<" "<<sqr(latt_en(EP[0],th_P[ith]))<<endl;
  out_disp_P<<"&"<<endl;
  
  //checking D dispertion relation
  ofstream out_disp_D(combine("plots/D_disp_rel_il_%d_ic_%d.xmg",il,ic).c_str());
  out_disp_D<<"@type xydy"<<endl;
  for(int ith=0;ith<nth;ith++) out_disp_D<<3*sqr(mom[ith])<<" "<<sqr(ED[ith])<<endl;
  out_disp_D<<"&"<<endl;
  for(int ith=0;ith<nth;ith++) out_disp_D<<3*sqr(mom[ith])<<" "<<sqr(cont_en(ED[0],th_P[ith]))<<endl;
  out_disp_D<<"&"<<endl;
  for(int ith=0;ith<nth;ith++) out_disp_D<<3*sqr(mom[ith])<<" "<<sqr(latt_en(ED[0],th_P[ith]))<<endl;
  out_disp_D<<"&"<<endl;
  
  //compute xi
  jvec xi(nth,njack);
  for(int ith=1;ith<nth;ith++)
    {
      int E_fit_reco_flag=0; //it makes no diff
      
      jack P0_th=E_fit_reco_flag?P0_r[ith]:P0[ith];
      jack Q0_th=E_fit_reco_flag?Q0_r[ith]:Q0[ith];
      
      xi[ith]=R2[ith]*P0_th;
      xi[ith]/=QK[ith]-R2[ith]*Q0_th;
    }
  
  //compute fP
  ofstream out_fP_r(combine("plots/fP_r_il_%d_ic_%d.xmg",il,ic).c_str());
  out_fP_r<<"@type xydy"<<endl;
  for(int ith=1;ith<nth;ith++)
    {
      int E_fit_reco_flag=1; //it makes no diff
      
      jack P0_th=E_fit_reco_flag?P0_r[ith]:P0[ith];
      jack Q0_th=E_fit_reco_flag?Q0_r[ith]:Q0[ith];
      
      jack c=P0_th/(ED[0]+EP[0])*(1+xi[ith]*Q0_th/P0_th);
      fP_r[ith]=R1[ith]/c*f0_r[0];

      out_fP_r<<Q2[ith].med()<<" "<<fP_r[ith]<<endl;
    }
  
  //compute f0 and fT
  ofstream out_f0_r(combine("plots/f0_r_il_%d_ic_%d.xmg",il,ic).c_str());
  ofstream out_fT_r(combine("plots/fT_r_il_%d_ic_%d.xmg",il,ic).c_str());;
  out_f0_r<<"@type xydy"<<endl;
  out_f0_r<<Q2[0].med()<<" "<<f0_r[0]<<endl;
  out_fT_r<<"@type xydy"<<endl;
  for(int ith=1;ith<nth;ith++)
    {
      //it seems better here to solve using reconstructed energies
      int E_fit_reco_flag=0;
  
      jack EP_th=E_fit_reco_flag?latt_en(EP[0],th_P[ith]):EP[ith];
      jack ED_th=E_fit_reco_flag?latt_en(ED[0],th_P[ith]):ED[ith];
      jack Q2_th=E_fit_reco_flag?Q2_r[ith]:Q2[ith];
      
      jack fM_r=xi[ith]*fP_r[ith]; //checked
      f0_r[ith]=fP_r[ith]+fM_r[ith]*Q2_th/(sqr(ED_th)-sqr(EP_th));
      
      out_f0_r<<Q2[ith].med()<<" "<<f0_r[ith]<<endl;
      
      fT_r[ith]=fM_r[ith]*RT[ith]*Zt_med[ibeta]/Zv_med[ibeta]*(EP[0]+ED[0])/(ED[ith]+EP[ith]); //ADD
      
      out_fT_r<<Q2[ith].med()<<" "<<fT_r[ith]<<endl;
    }
  
  
  //////////////////////////////////////// analytic method /////////////////////////////  
  
  jvec fP_a(nth,njack),fM_a(nth,njack),f0_a(nth,njack),fT_a(nth,njack);
  jvec fP_n(nth,njack),fM_n(nth,njack),f0_n(nth,njack),fT_n(nth,njack);
  
  //determine M and Z for pion and D
  jvec ZP(nth,njack),ZD(nth,njack);
  for(int ith=0;ith<nth;ith++)
    {
      jack E,Z2;
      two_pts_fit(E,Z2,P_corr[ith],tmin_P,TH);
      ZP[ith]=sqrt(Z2);
      two_pts_fit(E,Z2,D_corr[ith],tmin_D,TH);
      ZD[ith]=sqrt(Z2);
    }
  
  //compute V
  jvec VK_a(nth,njack),V0_a(nth,njack),TK_a(nth,njack);
  jvec VK_n(nth,njack),V0_n(nth,njack),TK_n(nth,njack);
  for(int ith=0;ith<nth;ith++)
    {
      ofstream out_V0(combine("plots/V0_il_%d_ic_%d_ith_%d_analytic_numeric.xmg",il,ic,ith).c_str());
      out_V0<<"@type xydy"<<endl;
      ofstream out_VK(combine("plots/VK_il_%d_ic_%d_ith_%d_analytic_numeric.xmg",il,ic,ith).c_str());
      out_VK<<"@type xydy"<<endl;
      ofstream out_TK(combine("plots/TK_il_%d_ic_%d_ith_%d_analytic_numeric.xmg",il,ic,ith).c_str());
      out_TK<<"@type xydy"<<endl;
      ofstream out_dt(combine("plots/dt_il_%d_ic_%d_ith_%d.xmg",il,ic,ith).c_str());
      out_dt<<"@type xydy"<<endl;
      
      //computing time dependance
      jvec dt_a(TH+1,njack),dt_n(TH+1,njack);
      {
	//it seems better here to use fitted energies
	int E_fit_reco_flag=1;
	jack EP_th=E_fit_reco_flag?latt_en(EP[0],th_P[ith]):EP[ith];
	jack ED_th=E_fit_reco_flag?latt_en(ED[0],th_P[ith]):ED[ith];
	
	for(int t=0;t<=TH;t++)
	  {
	    dt_a[t]=exp(-(ED_th*t+EP_th*(TH-t)))*ZP[0]*ZD[0]/(4*EP_th*ED_th);
	    dt_n[t]=D_corr[ith][t]*P_corr[ith][TH-t]/(ZD[0]*ZP[0]);
	  }
      }
      
      //remove time dependance using analytic or numeric expression
      jvec VK_corr_a=Zv_med[ibeta]*lcK_th[ith]/dt_a,V0_corr_a=Zv_med[ibeta]*lc0_th[ith]/dt_a;
      jvec VK_corr_n=Zv_med[ibeta]*lcK_th[ith]/dt_n,V0_corr_n=Zv_med[ibeta]*lc0_th[ith]/dt_n;
      jvec TK_corr_n=Zt_med[ibeta]*lcT_th[ith]/dt_n,TK_corr_a=Zt_med[ibeta]*lcT_th[ith]/dt_a;
      
      //fit V0
      V0_a[ith]=constant_fit(V0_corr_a,tmin,tmax);
      V0_n[ith]=constant_fit(V0_corr_n,tmin,tmax);
      out_V0<<write_constant_fit_plot(V0_corr_a,V0_a[ith],tmin,tmax)<<"&"<<endl;
      out_V0<<write_constant_fit_plot(V0_corr_n,V0_n[ith],tmin,tmax)<<"&"<<endl;
      
      //fit VK
      VK_a[ith]=constant_fit(VK_corr_a,tmin,tmax);
      VK_n[ith]=constant_fit(VK_corr_n,tmin,tmax);
      out_VK<<write_constant_fit_plot(VK_corr_a,VK_a[ith],tmin,tmax)<<"&"<<endl;
      out_VK<<write_constant_fit_plot(VK_corr_n,VK_n[ith],tmin,tmax)<<"&"<<endl;

      //fit TK
      TK_a[ith]=constant_fit(TK_corr_a,tmin,tmax);
      TK_n[ith]=constant_fit(TK_corr_n,tmin,tmax);
      out_TK<<write_constant_fit_plot(TK_corr_a,TK_a[ith],tmin,tmax)<<"&"<<endl;
      out_TK<<write_constant_fit_plot(TK_corr_n,TK_n[ith],tmin,tmax)<<"&"<<endl;
    }
  
  //compute f0(q2max)
  f0_a[0]=V0_a[0]/(ED[0]+EP[0]);
  f0_n[0]=V0_n[0]/(ED[0]+EP[0]);
  cout<<"f0_a["<<Q2[0].med()<<"]: "<<f0_a[0]<<endl;
  cout<<"f0_n["<<Q2[0].med()<<"]: "<<f0_n[0]<<endl;
  
  //solve for fP and f0
  for(int ith=1;ith<nth;ith++)
    {
      jack delta=P0[ith]*QK[ith]-Q0[ith]*PK[ith];

      //solve using analytic fit
      jack deltaP_a=V0_a[ith]*QK[ith]-Q0[ith]*VK_a[ith];
      jack deltaM_a=P0[ith]*VK_a[ith]-V0_a[ith]*PK[ith];  
      fP_a[ith]=deltaP_a/delta;
      fM_a[ith]=deltaM_a/delta;
      
      //solve using numeric fit
      jack deltaP_n=V0_n[ith]*QK[ith]-Q0[ith]*VK_n[ith];
      jack deltaM_n=P0[ith]*VK_n[ith]-V0_n[ith]*PK[ith];  
      fP_n[ith]=deltaP_n/delta;
      fM_n[ith]=deltaM_n/delta;

      //compute f0
      f0_a[ith]=fP_a[ith]+fM_a[ith]*Q2[ith]/(ED[0]*ED[0]-EP[0]*EP[0]);
      f0_n[ith]=fP_n[ith]+fM_n[ith]*Q2[ith]/(ED[0]*ED[0]-EP[0]*EP[0]);

      //solve fT
      fT_a[ith]=-TK_a[ith]*(EP[0]+ED[0])/(2*(ED[ith]+EP[ith]))/mom[ith];
      fT_n[ith]=-TK_n[ith]*(EP[0]+ED[0])/(2*(ED[ith]+EP[ith]))/mom[ith];
    }
  
  //write analytic and umeric plot of fP and f0
  ofstream out_fP_a("plots/fP_a.xmg"),out_fP_n("plots/fP_n.xmg");
  ofstream out_fM_a("plots/fM_a.xmg"),out_fM_n("plots/fM_n.xmg");
  ofstream out_f0_a("plots/f0_a.xmg"),out_f0_n("plots/f0_n.xmg");
  ofstream out_fT_a("plots/fT_a.xmg"),out_fT_n("plots/fT_n.xmg");
  out_fP_a<<"@type xydy"<<endl;
  out_fP_n<<"@type xydy"<<endl;
  out_f0_a<<"@type xydy"<<endl;
  out_f0_n<<"@type xydy"<<endl;
  out_fM_a<<"@type xydy"<<endl;
  out_fM_n<<"@type xydy"<<endl;
  out_fT_a<<"@type xydy"<<endl;
  out_fT_n<<"@type xydy"<<endl;
  out_f0_a<<Q2[0].med()<<" "<<f0_a[0]<<endl;
  out_f0_n<<Q2[0].med()<<" "<<f0_n[0]<<endl;
  for(int ith=1;ith<nth;ith++)
    {
      out_fP_a<<Q2[ith].med()<<" "<<fP_a[ith]<<endl;
      out_fP_n<<Q2[ith].med()<<" "<<fP_n[ith]<<endl;
      out_fM_a<<Q2[ith].med()<<" "<<fM_a[ith]<<endl;
      out_fM_n<<Q2[ith].med()<<" "<<fM_n[ith]<<endl;
      out_f0_a<<Q2[ith].med()<<" "<<f0_a[ith]<<endl;
      out_f0_n<<Q2[ith].med()<<" "<<f0_n[ith]<<endl;
      out_fT_a<<Q2[ith].med()<<" "<<fT_a[ith]<<endl;
      out_fT_n<<Q2[ith].med()<<" "<<fT_n[ith]<<endl;
    }
  
  ext_EP=EP;
  ext_ED=ED;
  ext_Q2=Q2;
  ext_fP=fP_a;
  ext_fM=fM_a;
  ext_f0=f0_a;
  ext_fT=fT_a;
}
Пример #20
0
TEST(SymbolTable, invalidName) {
  CompileErrorList errors;
  SymbolGraph graph;
  graph.addNode(Symbol(ZP("1A"), ZP("")));
  graph.addNode(Symbol(ZP("1_2"), ZP("")));
  graph.addNode(Symbol(ZP("#"), ZP("")));
  graph.addNode(Symbol(ZP("_---_"), ZP("")));
  graph.addNode(Symbol(ZP("-.-"), ZP("")));
  graph.addNode(Symbol(ZP("🅱🅻🅾🆇🆇"), ZP("")));
  graph.addNode(Symbol(ZP(""), ZP("")));
  auto eval = graph.evaluate();
  ASSERT_FALSE(eval.valid());
  ASSERT_EQ(eval.invalidNames().size(), 7);
}