void DirCurto (ApontadorNo *Ap, short *Fim){
    ApontadorNo Ap1;
    if ((*Ap)->BitD == Horizontal) {
        (*Ap)->BitD = Vertical;
        *Fim = TRUE;
        return;
    }
    if ((*Ap)->BitE == Horizontal) {
        Ap1 = (*Ap)->Esq;
        (*Ap)->Esq = Ap1->Dir;
        Ap1->Dir = *Ap;
        *Ap = Ap1;
        if ((*Ap)->Dir->Esq->BitD == Horizontal) {
            ED(&(*Ap)->Dir);
            (*Ap)->BitD = Horizontal;
        } else if ((*Ap)->Dir->Esq->BitE == Horizontal) {
            EE(&(*Ap)->Dir);
            (*Ap)->BitD = Horizontal;
        }
        *Fim = TRUE;
        return;
    }
    (*Ap)->BitE = Horizontal;
    if ((*Ap)->Esq->BitD == Horizontal) {
        ED(Ap);
        *Fim = TRUE;
        return;
    }
    if ((*Ap)->Esq->BitE == Horizontal) {
        EE(Ap);
        *Fim = TRUE;
    }
}
Пример #2
0
void IInsere(TipoReg x, TipoApont *Ap,TipoInclinacao *IAp, short *Fim)
{ if (*Ap == NULL)
  { *Ap = (TipoApont)malloc(sizeof(TipoNo));
    *IAp = Horizontal;  (*Ap)->Reg = x;
    (*Ap)->BitE = Vertical;  (*Ap)->BitD = Vertical;
    (*Ap)->Esq = NULL; (*Ap)->Dir = NULL; *Fim = FALSE;
    return;
  }
  if (x.Chave < (*Ap)->Reg.Chave)
  { IInsere(x, &(*Ap)->Esq, &(*Ap)->BitE, Fim);
    if (*Fim) return;
    if ((*Ap)->BitE != Horizontal) { *Fim = TRUE; return; }
    if ((*Ap)->Esq->BitE == Horizontal)
    { EE(Ap); *IAp = Horizontal; return; }
    if ((*Ap)->Esq->BitD == Horizontal) { ED(Ap); *IAp = Horizontal; }
    return;
  }
  //COMPARA플O AQUI
  if (x.Chave <= (*Ap)->Reg.Chave)
  { printf("Erro: Chave ja esta na arvore\n");
    *Fim = TRUE;
    return;
  }
  IInsere(x, &(*Ap)->Dir, &(*Ap)->BitD, Fim);
  if (*Fim) return;
  if ((*Ap)->BitD != Horizontal) { *Fim = TRUE;  return; }
  if ((*Ap)->Dir->BitD == Horizontal)
  { DD(Ap); *IAp = Horizontal; return;}
  if ((*Ap)->Dir->BitE == Horizontal) { DE(Ap); *IAp = Horizontal; }
}
Пример #3
0
int aes_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
               const unsigned char *in, size_t len)
{
    int block;
    int i, j;
    unsigned int mode, key_len;

    mode = EVP_CIPHER_CTX_mode(ctx) - 1;
    key_len = (ctx->key_len)/8 - 2;

    block = len / 16;

    for (i = 0; i < block; i++) {
        for (j = 0; j < 4; j++) {
            REG_TEXT(j) = GETU32(in + i*16 + j*4);
        }

        REG_AES = ED(0, key_len, ctx->encrypt, mode, 0, 0);

        int a[5];
        a[4] = REG_RESULT(0);
        for (j = 0; j < 4; j++) {
            a[j] = REG_RESULT(j);
        }

        for (j = 0; j < 4; j++) {
            PUTU32(a[j], out + i*16 + j*4);
        }
    }

    return 1;
}
Пример #4
0
void DirCurto(TipoApont *Ap, short *Fim)
{ /* Folha direita retirada => arvore curta na altura direita */
  TipoApont Ap1;
  if ((*Ap)->BitD == Horizontal)
  { (*Ap)->BitD = Vertical; *Fim = TRUE; return; }
  if ((*Ap)->BitE == Horizontal)
  { Ap1 = (*Ap)->Esq; (*Ap)->Esq = Ap1->Dir; Ap1->Dir = *Ap; *Ap = Ap1;
    if ((*Ap)->Dir->Esq->BitD == Horizontal)
    { ED(&(*Ap)->Dir); (*Ap)->BitD = Horizontal; }
    else if ((*Ap)->Dir->Esq->BitE == Horizontal)
         { EE(&(*Ap)->Dir); (*Ap)->BitD = Horizontal;}
    *Fim = TRUE;
    return;
  }
  (*Ap)->BitE = Horizontal;
  if ((*Ap)->Esq->BitD == Horizontal) { ED(Ap); *Fim = TRUE; return; }
  if ((*Ap)->Esq->BitE == Horizontal) { EE(Ap); *Fim = TRUE; }
}
Пример #5
0
 void axiom(VD axiom, Cost const& c = PT::start(), ED h = ED()) {
   SHOWIF2(TUHG, 3, c, axiom, TUHG_PRINT(axiom, g));
   Cost& mc = mu[axiom];
   if (PT::update(c, mc)) {
     assert(PT::includes(c, mc));
     safe_queue(axiom);
     if (pi) put(pi, axiom, h);
   } else {
     SHOWIF4(TUHG, 0, "WARNING: axiom didn't improve mu[axiom]", c, axiom, mu[axiom], TUHG_PRINT(axiom, g));
   }
 }
Пример #6
0
/* Only one triangle of the input matrix D is used (but a square
 * matrix is expected) */
void triangle_fixing_l2(
               /* IN+OUT */
	       double *D,		/* input matrix D, output M */
	       int *maxiter_p,		/* maximum iterations */
	       /* IN */
	       const int *n_p,		/* mtrx dimensions, int */
	       const double *kappa_p,	/* tolerance */
	       /* OUT */
	       double *delta_p		/* final sum of changes */
    ) {

    /* For convenience */
    n=*n_p;

    /* Initialize primal and dual */
    double *z = (double*) S_alloc(n*(n-1)*(n-2)/2,sizeof(double));

    *delta_p = 1.0 + *kappa_p;	/* first iteration */

    /* Convergence test */
    while( (*maxiter_p)-- && *delta_p > *kappa_p ) {

	size_t t=0;
	*delta_p=0.0;
	
	/* Foreach triangle inequality */
	for(size_t i=0; i<n; i++) {
	    for(size_t j=i+1; j<n; j++) {
		for(size_t k=j+1; k<n; k++) {
		    *delta_p += fixOneTriangle(D, i,j,k,z+t);
		    t++;
		    *delta_p += fixOneTriangle(D, j,k,i,z+t);
		    t++;
		    *delta_p += fixOneTriangle(D, k,i,j,z+t);
		    t++;
		}
	    }
	}
	/* delta = sum of changes in the e_ij values (?) */
    }

    for(size_t i=0; i<n; i++) {
	 for(size_t j=i+1; j<n; j++)  {
	      D[i*n+j]   =D[ED(i,j)]; /* symmetrize */
	 }
    }
    
    return;
}
void IInsere(TipoItem x, ApontadorNo *Ap, Inclinacao *IAp, short *Fim) {
  if (*Ap == NULL) {
  	*Ap = (ApontadorNo)malloc(sizeof(No));
    *IAp = Horizontal;
    (*Ap)->Reg = x;
    (*Ap)->BitE = Vertical;
    (*Ap)->BitD = Vertical;
    (*Ap)->Esq = NULL;
    (*Ap)->Dir = NULL;
    *Fim = FALSE;
    return;
  }
  if (x.cod < (*Ap)->Reg.cod) {
  	IInsere(x, &(*Ap)->Esq, &(*Ap)->BitE, Fim);
    if (*Fim)
		return;
    if ((*Ap)->BitE != Horizontal) {
    	*Fim = TRUE;
    	return;
	}
    if ((*Ap)->Esq->BitE == Horizontal) {
    	EE(Ap);
    	*IAp = Horizontal;
    	return;
	}
    if ((*Ap)->Esq->BitD == Horizontal) {
    	ED(Ap);
    	*IAp = Horizontal;
	}
    return;
  }
  IInsere(x, &(*Ap)->Dir, &(*Ap)->BitD, Fim);
  if (*Fim)
	return;
  if ((*Ap)->BitD != Horizontal) {
  	*Fim = TRUE;
  	return;
  }
  if ((*Ap)->Dir->BitD == Horizontal) {
  	DD(Ap);
  	*IAp = Horizontal;
  	return;
  }
  if ((*Ap)->Dir->BitE == Horizontal) {
  	DE(Ap);
  	*IAp = Horizontal;
  }
}
Пример #8
0
Файл: TEST.C Проект: xelax/orfe
main ()
{
	ED();
	SGR(CLEAR,WHITE,BLACK+BACK);
	printf("PROVA");
	SGR(UNDER,RED,BLACK+BACK);
	printf("PROVA");
	SGR(4,32,40);
	printf("PROVA");
	SGR(5,33,40);
	printf("PROVA");
	SGR(7,34,40);
	printf("PROVA");
	CUP(10,10);
	printf("1,10");
	CUP(10,20);
	printf("10,1");
	HVP(15,60);
	EL();
	printf("PROVA");
	SGR(0,0,0);
}
Пример #9
0
/* Mostly from http://suvrit.de/work/soft/metricn.html metricL2.cc */
double fixOneTriangle(double *D, size_t i, size_t j, size_t k,
		      double *err) {

    double oab, alpha = 0.0;
    double del;

    double ab = D[ED(i,j)];
    double bc = D[ED(j,k)];
    double ca = D[ED(i,k)];
    
    // Save leading edge for abc
    oab = ab;   
    
    alpha = *err;
    del = ab - bc - ca + 3*alpha;
    
    if (del < 0) {
      ab = ab + alpha;
      bc = bc - alpha;
      ca = ca - alpha;
    } else {
      del = del / 3;
      ab  = ab + alpha - del;
      bc  = bc + del - alpha;
      ca  = ca + del - alpha;
    }

    D[ED(i,j)]=ab;
    D[ED(j,k)]=bc;
    D[ED(i,k)]=ca;
    
    /* gsl_matrix_set(d, i, j, ab); */
    /* gsl_matrix_set(d, j, k, bc); */
    /* gsl_matrix_set(d, i, k, ca); */

    *err = oab - ab + *err;
    double echange = fabs(ab - oab);
    return echange;
    
}
Пример #10
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;
}
Пример #11
0
 void init_pi(ED null = ED()) {
   if (pi) graehl::init_pmap(vertexT, g, pi, null);
 }