예제 #1
0
//stack[sp] is current color index
static void text_color(char c, char *stack, int size, int &sp, bvec color, int a)
{
    if(c=='s') // save color
    {
        c = stack[sp];
        if(sp<size-1) stack[++sp] = c;
    }
    else
    {
        xtraverts += varray::end();
        if(c=='r') c = stack[(sp > 0) ? --sp : sp]; // restore color
        else stack[sp] = c;
        switch(c)
        {
            case '0': color = bvec( 64, 255, 128); break;   // green: player talk
            case '1': color = bvec( 96, 160, 255); break;   // blue: "echo" command
            case '2': color = bvec(255, 192,  64); break;   // yellow: gameplay messages
            case '3': color = bvec(255,  64,  64); break;   // red: important errors
            case '4': color = bvec(128, 128, 128); break;   // gray
            case '5': color = bvec(192,  64, 192); break;   // magenta
            case '6': color = bvec(255, 128,   0); break;   // orange
            case '7': color = bvec(255, 255, 255); break;   // white
            case '8': color = bvec(0, 0, 0); break;   // black
        }
        glColor4ub(color.x, color.y, color.z, a);
    }
}
예제 #2
0
파일: lcp.cpp 프로젝트: order/lcp-research
LCP augment_lcp(const LCP & original,
                vec & x,
                vec & y,
                double scale){
  cout << "Scale: " << scale << endl;
  uint N = original.q.n_elem;
  x = ones<vec>(N);
  y = ones<vec>(N);
  y(find(1 == original.free_vars)).fill(0);
  
  vec r = y - (original.M * x + original.q); // Initial residual
  //[M r]
  //[0 s]
  sp_mat M = sp_mat(N+1,N+1);
  M(span(0,N-1),span(0,N-1)) = original.M;
  M(span(0,N-1),N) = r;
  M(N,N) = scale;

  vec q = vec(N+1);
  q.head(N) = original.q;
  q(N) = 0;

  x.resize(N+1);
  x(N) = 1;
  y.resize(N+1);
  y(N) = scale;

  // New variable is non-negative; all others same.
  bvec free_vars = bvec(N+1);
  free_vars.head(N) = original.free_vars;
  free_vars(N) = 0;
  
  return LCP(M,q,free_vars);
}
예제 #3
0
const glsl_type *
glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
{
   if (base_type == GLSL_TYPE_VOID)
      return void_type;

   if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4))
      return error_type;

   /* Treat GLSL vectors as Nx1 matrices.
    */
   if (columns == 1) {
      switch (base_type) {
      case GLSL_TYPE_UINT:
	 return uvec(rows);
      case GLSL_TYPE_INT:
	 return ivec(rows);
      case GLSL_TYPE_FLOAT:
	 return vec(rows);
      case GLSL_TYPE_BOOL:
	 return bvec(rows);
      default:
	 return error_type;
      }
   } else {
      if ((base_type != GLSL_TYPE_FLOAT) || (rows == 1))
	 return error_type;

      /* GLSL matrix types are named mat{COLUMNS}x{ROWS}.  Only the following
       * combinations are valid:
       *
       *   1 2 3 4
       * 1
       * 2   x x x
       * 3   x x x
       * 4   x x x
       */
#define IDX(c,r) (((c-1)*3) + (r-1))

      switch (IDX(columns, rows)) {
      case IDX(2,2): return mat2_type;
      case IDX(2,3): return mat2x3_type;
      case IDX(2,4): return mat2x4_type;
      case IDX(3,2): return mat3x2_type;
      case IDX(3,3): return mat3_type;
      case IDX(3,4): return mat3x4_type;
      case IDX(4,2): return mat4x2_type;
      case IDX(4,3): return mat4x3_type;
      case IDX(4,4): return mat4_type;
      default: return error_type;
      }
   }

   assert(!"Should not get here.");
   return error_type;
}
예제 #4
0
//===========================================================================
///	GetSaliencyMap
///
/// Outputs a saliency map with a value assigned per pixel. The values are
/// normalized in the interval [0,255] if normflag is set true (default value).
//===========================================================================
void Saliency::GetSaliencyMap(
	const vector<UINT>&				inputimg,
	const int&						width,
	const int&						height,
	vector<double>&					salmap,
	const bool&						normflag) 
{
	int sz = width*height;
	salmap.clear();
	salmap.resize(sz);

	vector<double> lvec(0), avec(0), bvec(0);
	RGB2LAB(inputimg, lvec, avec, bvec);
	//--------------------------
	// Obtain Lab average values
	//--------------------------
	double avgl(0), avga(0), avgb(0);
	{for( int i = 0; i < sz; i++ )
	{
		avgl += lvec[i];
		avga += avec[i];
		avgb += bvec[i];
	}}
	avgl /= sz;
	avga /= sz;
	avgb /= sz;

	vector<double> slvec(0), savec(0), sbvec(0);

	//----------------------------------------------------
	// The kernel can be [1 2 1] or [1 4 6 4 1] as needed.
	// The code below show usage of [1 2 1] kernel.
	//----------------------------------------------------
	vector<double> kernel(0);
	kernel.push_back(1.0);
	kernel.push_back(2.0);
	kernel.push_back(1.0);

	GaussianSmooth(lvec, width, height, kernel, slvec);
	GaussianSmooth(avec, width, height, kernel, savec);
	GaussianSmooth(bvec, width, height, kernel, sbvec);

	{for( int i = 0; i < sz; i++ )
	{
		salmap[i] = (slvec[i]-avgl)*(slvec[i]-avgl) +
					(savec[i]-avga)*(savec[i]-avga) +
					(sbvec[i]-avgb)*(sbvec[i]-avgb);
	}}

	if( true == normflag )
	{
		vector<double> normalized(0);
		Normalize(salmap, width, height, normalized);
		swap(salmap, normalized);
	}
}
예제 #5
0
 int addvert(const vec &pos, const vec2 &tc = vec2(0, 0), const bvec &norm = bvec(128, 128, 128), const bvec &tangent = bvec(128, 128, 128), uchar bitangent = 128)
 {
     vertex vtx;
     vtx.pos = pos;
     vtx.tc = tc;
     vtx.norm = norm;
     vtx.reserved = 0;
     vtx.tangent = tangent;
     vtx.bitangent = bitangent;
     return addvert(vtx);
 }
예제 #6
0
void CRC_Code::set_code(const std::string &code)
{
  bvec poly;
  for (int i = 0; i < 18;i++) {
    if (crccode[i][0] == code)
      poly = bvec(crccode[i][1]);
  }

  if ((code == "WCDMA-8") || (code == "WCDMA-12") || (code == "WCDMA-16") || (code == "WCDMA-24")) {
    reverse_parity = true;
  }

  it_assert(poly.size() > 0, "This CRC code doesn't exist in the tables");
  set_generator(poly);
}
//******************************************
VOID	nu_to_n1_vec(
USHORT 					num_of_bits,		//in
VECTOR<DOUBLE>  &		in_vec)				//io
{
	//As in Latex, let _beta mean a subscript of beta.
	//For bit beta, define
	//n(beta) = diag(0,1)_beta, 
	//u(beta) = nbar(beta) = 1 - n(beta) = diag(1,0)_beta
	//1_beta = diag(1,1)_beta
	//This method replaces in_vec (a vector from the n,u basis) by 
	//its equivalent in the n,1 basis
	//example:
	//2 bits
	//A00 u(1)u(0) = A00 [ ( 1)*1 + (-1)*n(0) + (-1)*n(1) + ( 1)*n(1)n(0) ]
	//A01 u(1)n(0) = A01 [ ( 0)*1 + ( 1)*n(0) + ( 0)*n(1) + (-1)*n(1)n(0) ]
	//A10 n(1)u(0) = A10 [ ( 0)*1 + ( 0)*n(0) + ( 1)*n(1) + (-1)*n(1)n(0) ]
	//A11 n(1)n(0) = A11 [ ( 0)*1 + ( 0)*n(0) + ( 0)*n(1) + ( 1)*n(1)n(0) ]
	//vector in n,u basis: [A00, A01, A10, A11]
	//vector in n,1 basis: [B00, B01, B10, B11]
	//where
	//B00 = A00*( 1)
	//B01 = A00*(-1) + A01*( 1)
	//B10 = A00*(-1) + A01*( 0) + A10*( 1)
	//B11 = A00*( 1) + A01*(-1) + A10*(-1) + A11*( 1)
	

	if(num_of_bits==0)return;//do nothing since only one component

	USHORT	num_of_comps = (1 << num_of_bits);
	ThrowIf_(in_vec.get_len()!=num_of_comps);
	
	VECTOR<DOUBLE>	n1_vec(0, num_of_comps);
	BIT_VECTOR		bvec(num_of_bits, 0);
	for(USHORT i_n1=0; i_n1<num_of_comps; i_n1++){
		for(USHORT i_nu=0; i_nu<=i_n1; i_nu++){
			if( (i_nu & i_n1)==i_nu ){
				//remember that i^j is bitwise mod2 addition of i and j
				bvec.set_dec_rep(i_nu ^ i_n1);
				if(bvec.get_num_of_ON_bits()%2){//bvec.num_of_ON_bits is odd
					n1_vec[i_n1] -= in_vec[i_nu];
				}else{//bvec.num_of_ON_bits is even
					n1_vec[i_n1] += in_vec[i_nu];
				}
			}
		}
	}
	in_vec = n1_vec;
}
예제 #8
0
int main(int narg,char **arg)
{
  init_latpars();
  
  //read ensemble list, meson masses and meson name
  FILE *an_input_file=open_file("analysis_pars","r");
  read_formatted_from_file_expecting((char*)&approx_Pi_FSE,an_input_file,"%d","approx_Pi_FSE");
  read_formatted_from_file_expecting((char*)&approx_K_FSE,an_input_file,"%d","approx_K_FSE");
  read_formatted_from_file_expecting((char*)&nens,an_input_file,"%d","nens");
  lmass=new double[nens];
  L=new int[nens];
  ibeta=new int[nens];
  FSE_K_corr=new double[nens];
  H1_corr=new double[nens];
  H2_corr=new double[nens];
  dM2Pi=bvec(nens,nboot,njack);
  dM2K=bvec(nens,nboot,njack);
  MPi=bvec(nens,nboot,njack);
  MK=bvec(nens,nboot,njack);
  eps_gam=bvec(nens,nboot,njack);
  
  ofstream bare_data_table("bare_data_table");
  ofstream dim_data_table("dim_data_table");
  
  for(int iens=0;iens<nens;iens++)
    {
      char path[1024];
      read_formatted_from_file((char*)&(ibeta[iens]),an_input_file,"%d","ibeta");
      read_formatted_from_file((char*)&(lmass[iens]),an_input_file,"%lg","lmass");
      read_formatted_from_file((char*)&(L[iens]),an_input_file,"%d","L");
      read_formatted_from_file((char*)&(H1_corr[iens]),an_input_file,"%lg","H1_corr");
      read_formatted_from_file((char*)&(H2_corr[iens]),an_input_file,"%lg","H2_corr");
      read_formatted_from_file((char*)&(FSE_K_corr[iens]),an_input_file,"%lg","FSE_K_corr");
      read_formatted_from_file(path,an_input_file,"%s","path");
      
      //load bare data
      jack aMPi(njack),aMK(njack);
      jack a2dM2Pi(njack),a2dM2K(njack);
      aMPi.load(combine("../%s/MPi",path).c_str());
      a2dM2Pi.load(combine("../%s/DeltaM2Pi",path).c_str());
      aMK.load(combine("../%s/MK",path).c_str());
      a2dM2K.load(combine("../%s/DeltaM2K",path).c_str());
      
      //write the bare data table
      bare_data_table<<iens<<" "<<smart_print(aMPi)<<" "<<smart_print(aMK)<<" "<<smart_print(a2dM2Pi)<<" "<<smart_print(a2dM2K)<<endl;
      
      //load iboot
      int iboot_jack[100];
      load_iboot(iboot_jack,path);
      
      //convert jack from boot
      boot_from_jack(MPi.data[iens],aMPi,iboot_jack);
      boot_from_jack(MK.data[iens],aMK,iboot_jack);
      boot_from_jack(dM2Pi.data[iens],a2dM2Pi,iboot_jack);
      boot_from_jack(dM2K.data[iens],a2dM2K,iboot_jack);
      MPi[iens]/=lat[ibeta[iens]];
      MK[iens]/=lat[ibeta[iens]];
      dM2Pi[iens]/=-sqr(lat[ibeta[iens]]);
      dM2K[iens]/=sqr(lat[ibeta[iens]]);
      eps_gam[iens]=dM2K[iens]/dM2Pi[iens]-1;
      
      //write the dimensional data table
      dim_data_table<<iens<<" "<<smart_print(MPi[iens])<<" "<<smart_print(MK[iens])<<" "
		    <<smart_print(dM2Pi[iens])<<" "<<smart_print(dM2K[iens])<<endl;
    }
  fclose(an_input_file);
  
  //define ml and ref ml
  ml=bvec(nens,nboot,njack);
  for(int iens=0;iens<nens;iens++)
    {
      int b=ibeta[iens],r=ref_ml_beta[b];
      //define ml
      cout<<iens<<" "<<b<<" "<<lmass[iens]<<endl;
      ml[iens]=lmass[iens]/lat[b]/Zp[b];
      //set the lighter mass
      if(r==-1||fabs(ml[r].med()-0.050)>fabs(ml[iens].med()-0.050)) ref_ml_beta[b]=iens;
    }
  cout<<"---"<<endl;
  for(int ib=0;ib<nbeta;ib++)
    if(ref_ml_beta[ib]!=-1)
      cout<<"Ref "<<ib<<" = "<<ref_ml_beta[ib]<<", "<<smart_print(ml[ref_ml_beta[ib]]*1e3)<<" MeV"<<endl;
  cout<<"---"<<endl;

  //perform the fit
  boot A(nboot,njack),B(nboot,njack),C(nboot,njack),D(nboot,njack);
  fit(A,B,C,D);
  
  //chiral extrapolation
  bvec dM2Pi_chir(nbeta,nboot,njack),dM2K_chir(nbeta,nboot,njack);
  boot dM2Pi_chir_cont(nboot,njack),dM2K_chir_cont(nboot,njack);
  bvec dM2Pi_estr_ml(nbeta,nboot,njack),dM2K_estr_ml(nbeta,nboot,njack);
  boot eps_gam_chir_cont(nboot,njack);
  
  //take extrapolation
  for(int iboot=0;iboot<nboot+1;iboot++)
    {
      dM2Pi_chir_cont.data[iboot]=fun_fit(A[iboot],B[iboot],C[iboot],D[iboot],ml_phys[iboot],ml_phys[iboot],0);
      dM2K_chir_cont.data[iboot]=fun_fit(A[iboot],B[iboot],C[iboot],D[iboot],ml_phys[iboot],ms_phys[iboot],0);
      eps_gam_chir_cont.data[iboot]=dM2K_chir_cont.data[iboot]/dM2Pi_chir_cont.data[iboot]-1;
      for(int ib=0;ib<nbeta;ib++)
	{
	  int r=ref_ml_beta[ib];
	  dM2Pi_chir[ib].data[iboot]=fun_fit(A[iboot],B[iboot],C[iboot],D[iboot],ml_phys[iboot],ml_phys[iboot],lat[ib][iboot]);
	  dM2K_chir[ib].data[iboot]=fun_fit(A[iboot],B[iboot],C[iboot],D[iboot],ml_phys[iboot],ms_phys[iboot],lat[ib][iboot]);
	  if(r!=-1)
	    {
	      dM2Pi_estr_ml.data[ib].data[iboot]=dM2Pi[r][iboot]*
		fun_fit(A[nboot],B[nboot],C[nboot],D[nboot],ml_phys[nboot],ml_phys[nboot],0)/
		fun_fit(A[nboot],B[nboot],C[nboot],D[nboot],ml[r][nboot],ml[r][nboot],0);
	      dM2K_estr_ml.data[ib].data[iboot]=dM2Pi[r][iboot]*
		fun_fit(A[nboot],B[nboot],C[nboot],D[nboot],ml_phys[nboot],ms_phys[nboot],0)/
		fun_fit(A[nboot],B[nboot],C[nboot],D[nboot],ml[r][nboot],ms_phys[nboot],0);
	    }
	}
    }
  
  //chiral and continuum
  cout<<"dM2Pi = "<<smart_print(dM2Pi_chir_cont*1e6)<<" MeV^2, physical: 1261 MeV^2"<<endl;
  cout<<"dM2K = "<<smart_print(dM2K_chir_cont*1e6)<<" MeV^2, \"physical(eps=0.7)\": 2000 MeV^2"<<endl;
  cout<<endl;
  
  //plots
  par_res_fit=bvec(4,nboot,njack);
  
  par_res_fit.data[0]=A;
  par_res_fit.data[1]=B;
  par_res_fit.data[2]=C;
  par_res_fit.data[3]=D;
  
  const char tag_ml[1024]="m\\sl\\N\\S\\oMS\\O,2GeV\\N (GeV)";
  const char tag_a2[1024]="a\\S2\\N (fm)";
  double lat_med_fm[4]={lat[0].med()*hc,lat[1].med()*hc,lat[2].med()*hc,lat[3].med()*hc};

  char dM2Pi_label[]={"\\xD\\0M\\S2\\N\\s\\xp\\N\\0 (GeV\\S2\\N)"};
  char dM2K_label[]={"\\xD\\0M\\S2\\N\\sK\\N (GeV\\S2\\N)"};
  char eps_gam_label[]={"\\xe\\0\\s\\xg"};
  
  //compute the corrections
  bvec corr_dM2Pi(nens,nboot,njack),corr_dM2K(nens,nboot,njack);
  for(int iens=0;iens<nens;iens++)
    {
      for(int iboot=0;iboot<nboot+1;iboot++)
	{
	  corr_dM2Pi[iens].data[iboot]=fin_inf_diff(A[iboot],iens,MPi[iens][iboot],fun_fit(A[iboot],B[iboot],C[iboot],D[iboot],ml[iens][iboot],ml[iens][iboot],lat[ibeta[iens]][iboot]),0);
	  corr_dM2K[iens].data[iboot]=fin_inf_diff(A[iboot],iens,MK[iens][iboot],fun_fit(A[iboot],B[iboot],C[iboot],D[iboot],ml[iens][iboot],ms_phys[iboot],lat[ibeta[iens]][iboot]),1);
	}
      
      cout<<iens<<" corr_Pi: "<<smart_print(corr_dM2Pi[iens])<<", corr_K: "<<smart_print(corr_dM2K[iens])<<endl;
    }
  
  plot_funz_ml("dM2Pi_funz_ml.xmg",dM2Pi_label,tag_ml,dM2Pi_label,ml,dM2Pi,corr_dM2Pi,par_res_fit,ml_phys.med(),dM2Pi_chir_cont,0);
  plot_funz_a2("dM2Pi_funz_a2.xmg",dM2Pi_label,tag_a2,dM2Pi_label,lat_med_fm,dM2Pi_estr_ml,par_res_fit,dM2Pi_chir_cont,0);
    
  plot_funz_ml("dM2K_funz_ml.xmg",dM2K_label,tag_ml,dM2K_label,ml,dM2K,corr_dM2K,par_res_fit,ml_phys.med(),dM2K_chir_cont,1);
  plot_funz_a2("dM2K_funz_a2.xmg",dM2K_label,tag_a2,dM2K_label,lat_med_fm,dM2K_estr_ml,par_res_fit,dM2K_chir_cont,1);

  plot_funz_ml("eps_gam.xmg",eps_gam_label,tag_ml,"",ml,eps_gam,corr_dM2Pi*0,par_res_fit,ml_phys.med(),eps_gam_chir_cont,2);

  //write results  
  dM2Pi_chir_cont.write_to_binfile("result_dM2Pi");
  dM2K_chir_cont.write_to_binfile("result_dM2K");

  
  return 0;
}
예제 #9
0
int main(int narg,char **arg)
{
    init_latpars();

    //read ensemble list, meson masses and meson name
    FILE *an_input_file=open_file("analysis_pars","r");
    char ens_list_path[1024],meson_P5P5_file[1024],meson_VKVK_file[1024],meson_name[1024];
    read_formatted_from_file_expecting(ens_list_path,an_input_file,"%s","ens_list_path");
    read_formatted_from_file_expecting(meson_P5P5_file,an_input_file,"%s","meson_mass_P5P5_file");
    read_formatted_from_file_expecting(meson_VKVK_file,an_input_file,"%s","meson_mass_VKVK_file");
    read_formatted_from_file_expecting(meson_name,an_input_file,"%s","meson_name");
    fclose(an_input_file);

    //load ensembles list and parameters
    load_ensembles_list(base_corrs_path,ens_name,nens,T,ibeta,nmass,mass,iml_un,nlights,ens_list_path);

    //define ml and ref ml
    ml=bvec(nens,nboot,njack);
    for(int iens=0; iens<nens; iens++)
    {
        int b=ibeta[iens],r=ref_ml_beta[b];
        //define ml
        cout<<iens<<" "<<b<<" "<<iml_un[iens]<<" "<<mass[iens][iml_un[iens]]<<endl;
        ml[iens]=mass[iens][iml_un[iens]]/lat[b]/Zp[b];
        //set the lighter mass
        if(r==-1||ml[r].med()>ml[iens].med()) ref_ml_beta[b]=iens;
    }
    cout<<"---"<<endl;
    for(int ib=0; ib<nbeta; ib++) if(ref_ml_beta[ib]!=-1) cout<<"Ref "<<ib<<" = "<<ref_ml_beta[ib]<<", "<<ml[ref_ml_beta[ib]]<<" MeV"<<endl;
    cout<<"---"<<endl;

    //load data
    diff=bvec(nens,nboot,njack);

    bvec cP5P5(nens,nboot,njack);
    cP5P5.load(meson_P5P5_file,0);
    bvec cVKVK(nens,nboot,njack);
    cVKVK.load(meson_VKVK_file,0);
    diff=(sqr(cVKVK)-sqr(cP5P5))/(2*cVKVK)/sqrt(3)/(2*M_PI);

    //perform the fit
    boot A(nboot,njack),B(nboot,njack),C(nboot,njack);
    fit(A,B,C,ml,diff);
    cout<<endl;

    //chiral extrapolation
    boot diff_chir[nbeta],diff_chir_cont(nboot,njack);
    bvec diff_estr_ml(nbeta,nboot,njack);
    for(int ib=0; ib<nbeta; ib++)
    {
        diff_chir[ib]=boot(nboot,njack);
        for(int iboot=0; iboot <nboot+1; iboot++)
        {
            int r=ref_ml_beta[ib];
            diff_chir_cont.data[iboot]=fun_fit_diff(A[iboot],B[iboot],C[iboot],ml_phys[iboot],0);
            diff_chir[ib].data[iboot]=fun_fit_diff(A[iboot],B[iboot],C[iboot],ml_phys[iboot],lat[ib][iboot]);

            if(r!=-1) diff_estr_ml.data[ib].data[iboot]=diff[r][iboot]*fun_fit_diff(A[iboot],B[iboot],C[iboot],ml_phys[iboot],0)/fun_fit_diff(A[iboot],B[iboot],C[iboot],ml[r][iboot],0);
        }
    }

    for(int iens=0; iens<nens; iens++)
    {
        boot P=cP5P5[iens]*lat[ibeta[iens]];
        boot V=cVKVK[iens]*lat[ibeta[iens]];
        boot N=V*V-P*P;
        boot D=2*V;
        boot qabs=N/D;
        boot q=qabs/sqrt(3);
        boot th=q*T[iens]/(2*M_PI);
        boot th_teo(nboot,njack);
        for(int iboot=0; iboot<=nboot; iboot++)
        {
            int b=ibeta[iens];
            double Ab=A[iboot];
            double Bb=B[iboot];
            double Cb=C[iboot];
            double a=lat[b][iboot];
            double z=Zp[b][iboot];
            double m=mass[iens][iml_un[iens]]/a/z;
            th_teo.data[iboot]=fun_fit_diff(Ab,Bb,Cb,m,a)*T[iens]*a;
        }
        //cout<<iens<<" "<<mass[iens][iml_un[iens]]<<" "<<(diff[iens]*lat[ibeta[iens]])*(T[iens]/2.0/(3.14159*sqrt(3)))<<endl;
        cout<<iens<<"\t"<<mass[iens][iml_un[iens]]<<"\t"<<V<<"\t"<<P<<"\t"<<th<<" "<<th_teo<<endl;
    }

    //chiral and continuum
    cout<<"diff = ("<<diff_chir_cont*1000<<") MeV"<<endl;
    diff_chir_cont.write_to_binfile("diff");

    par_res_fit_diff=bvec(3,nboot,njack);

    par_res_fit_diff.data[0]=A;
    par_res_fit_diff.data[1]=B;
    par_res_fit_diff.data[2]=C;

    const char tag_ml[1024]="m\\sl\\N\\SMS,2GeV\\N (GeV)";
    const char tag_a2[1024]="a\\S2\\N (fm)";
    double lat_med_fm[4]= {lat[0].med()*hc,lat[1].med()*hc,lat[2].med()*hc,lat[3].med()*hc};

    plot_funz_ml("diff_funz_ml.xmg",meson_name,tag_ml,meson_name,ml,diff,par_res_fit_diff,ml_phys.med(),fun_fit_diff,diff_chir_cont);
    plot_funz_a2("diff_funz_a2.xmg",meson_name,tag_a2,meson_name,lat_med_fm,diff_estr_ml,par_res_fit_diff,fun_fit_diff,diff_chir_cont);

    cout<<mc_phys*Zp[2]*lat[2]<<endl;

    return 0;
}
예제 #10
0
파일: msbsvar_irf.cpp 프로젝트: cran/MSBVAR
SEXP msbsvar_irf(SEXP gibbs, SEXP msbsvar, SEXP nsteps)
{
  int i, k, n, N2, h, m, p, n0max, ns=INTEGER(nsteps)[0];
  int *db, *dF, *dxi, *dQ, N210pct, pctct=0;
  SEXP bR, FR, xiR, QR, Ui, IRFlist, IRFtmp;

//   Rprintf("ns = %d\n",ns); 
  
  // Get b, F, xi, Q, SS, dims from gibbs object
  PROTECT(bR = VECTOR_ELT(gibbs,0)); db=getdims(bR);
//   Rprintf("b(%d,%d)\n",db[0],db[1]); 
  PROTECT(FR = VECTOR_ELT(gibbs,1)); dF=getdims(FR);
//   Rprintf("F(%d,%d)\n",dF[0],dF[1]); 
  PROTECT(xiR= VECTOR_ELT(gibbs,2)); dxi=getdims(xiR);
//   Rprintf("xi(%d,%d)\n",dxi[0],dxi[1]); 
  PROTECT(QR = VECTOR_ELT(gibbs,3)); dQ=getdims(QR); UNPROTECT(1); 
//   Rprintf("Q(%d,%d)\n",dQ[0],dQ[1]); 
  
//   Rprintf("Gibbs Objects and Dimensions Assigned\n"); 
  
  // Reconstruct constants
  N2=db[0]; h=(int)sqrt((double)dQ[1]); n0max=db[1]/h; m=dxi[1]/h; p=((dF[1]/(h*m))-1)/m;
  N210pct=N2/10; 

//   Rprintf("N2=%d\nh=%d\nm=%d\np=%d\nn0max=%d\n",N2,h,m,p,n0max); 

  // Get Ui from msbsvar
  PROTECT(Ui=VECTOR_ELT(msbsvar,7));
 
  Matrix bsample=R2Cmat(bR,N2,n0max*h);
  Matrix Fsample=R2Cmat(FR,N2,m*(m*p+1)*h); 
  Matrix xisample=R2Cmat(xiR,N2,m*h);

  ColumnVector bk(n0max), Fk(m*(m*p+1)), bvec(m*m*p); bk=0.0; Fk=0.0; bvec=0.0; 
  DiagonalMatrix xik(m), sqrtxik(m); xik=0.0; sqrtxik=0.0; 
  Matrix Q(h,h), A0(m,m), A0i(m,m), fmat(m,m*p+1), sqrtwish, impulse(N2,m*m*ns); 
  double *pFk; int IRFdims[]={N2,ns,m*m};   

  PROTECT(IRFlist=allocVector(VECSXP,h)); 
  // Loop over regimes 
  for(k=1;k<=h;k++){
    
//     Rprintf("\n==========\nRegime %d\n==========\n",k);
    pctct=0;
    // Compute impulse responses for every draw of regime k
    for(n=1;n<=N2;n++){
//        Rprintf("\nDraw %d:\n",n); 

      // Get values for draw 'n', regime 'k' 
      bk=bsample.SubMatrix(n,n,(k-1)*n0max+1,k*n0max).t();
//       Rprintf("--bk(%d): ",bk.Storage()); //printCVector(bk); 
      Fk=Fsample.SubMatrix(n,n,(k-1)*m*(m*p+1)+1,k*m*(m*p+1)).t(); pFk=Fk.Store(); 
//       Rprintf("--Fk(%d): ",Fk.Storage()); //printCVector(Fk); 

      for(i=1;i<=m;i++) xik(i)=sqrt(xisample(n,(k-1)*m+i)); 
//       Rprintf("--xik(%d)/sqrtxik(%d) defined\n",m,m); 

      // Compute A0/A0^-1/sqrtwish for regime k
      A0=b2a(bk,Ui); 
      //Rprintf("--A0(%d,%d):",m,m); //printMatrix(A0); 
      A0i=A0.i(); 
      //Rprintf("--A0^-1(%d,%d):",m,m); //printMatrix(A0i); 
      sqrtwish=(A0*xik).i(); 
      //Rprintf("--sqrtwish(%d,%d):",m,m); //printMatrix(sqrtwish); 

      // Compute beta vector 
      fmat.ReSize(m,m*p+1); fmat<<pFk; fmat=fmat.t(); 
      fmat=(fmat.Rows(1,m*p)*A0i).t(); bvec=fmat.AsColumn(); 
//       Rprintf("--fmat(%d,%d):",m,m*p+1); printMatrix(fmat); 
//       Rprintf("bvec_%d:", n); printCVector(bvec);
      
      // Compute IRF 
      impulse.Row(n)=irf_var_from_beta(sqrtwish.t(), bvec, ns).t(); 
      if (!(n%N210pct))
	Rprintf("Regime %d: Monte Carlo IRF %d percent complete (Iteration %d)\n",k,++pctct*10,n);
    }

    // Create and class Robj for impulses, load into IRFlist
    PROTECT(IRFtmp=C2R3D(impulse,IRFdims)); 
    setclass(IRFtmp,"mc.irf.BSVAR"); SET_VECTOR_ELT(IRFlist, k-1, IRFtmp); 
    UNPROTECT(1); 
  }
  UNPROTECT(5); 
  return IRFlist;
}
예제 #11
0
int main(int narg,char **arg)
{
  init_latpars();
  
  //read ensemble list, meson phiD and meson name
  FILE *an_input_file=open_file("analysis_pars","r");
  char ens_list_path[1024],meson_phi_file[1024],meson_name[1024];
  read_formatted_from_file_expecting(ens_list_path,an_input_file,"%s","ens_list_path");
  read_formatted_from_file_expecting(meson_phi_file,an_input_file,"%s","meson_phi_file");
  read_formatted_from_file_expecting(meson_name,an_input_file,"%s","meson_name");
  read_formatted_from_file_expecting((char*)&ghat_ave,an_input_file,"%lg","ghat");
  read_formatted_from_file((char*)&ghat_err,an_input_file,"%lg","ghat_err");
  fclose(an_input_file);
  
  //prepar the ghat
  ghat=boot(nboot,njack);
  ghat.fill_gauss(ghat_ave,ghat_err,25252352);
  
  //load ensembles list and parameters
  load_ensembles_list(base_corrs_path,ens_name,nens,T,ibeta,nmass,mass,iml_un,nlights,ens_list_path);
  
  //define ml and ref ml, and chiral logs
  ml=bvec(nens,nboot,njack);
  for(int iens=0;iens<nens;iens++)
    {
      int b=ibeta[iens],r=ref_ml_beta[b];
      //define ml
      cout<<iens<<" "<<b<<" "<<iml_un[iens]<<" "<<mass[iens][iml_un[iens]]<<endl;
      ml[iens]=mass[iens][iml_un[iens]]/lat[b]/Zp[b];
      
      //set the lighter mass
      if(r==-1||ml[r].med()>ml[iens].med()) ref_ml_beta[b]=iens;
    }
  cout<<"---"<<endl;
  for(int ib=0;ib<nbeta;ib++) if(ref_ml_beta[ib]!=-1) cout<<"Ref "<<ib<<" = "<<ref_ml_beta[ib]<<", "<<ml[ref_ml_beta[ib]]<<" MeV"<<endl;
  cout<<"---"<<endl;

  //load data
  phiD=bvec(nens,nboot,njack);
  phiD.load(meson_phi_file,0);  

  //perform the fit
  boot A(nboot,njack),B(nboot,njack),C(nboot,njack);
  fit(A,B,C,ml,phiD);
  cout<<endl;
  
  //chiral extrapolation
  boot phiD_chir[nbeta],phiD_chir_cont(nboot,njack);
  bvec phiD_estr_ml(nbeta,nboot,njack),fD_estr_ml(nbeta,nboot,njack);
  for(int ib=0;ib<nbeta;ib++)
    {
      phiD_chir[ib]=boot(nboot,njack);
      for(int iboot=0;iboot<nboot+1;iboot++)
	{
	  int r=ref_ml_beta[ib];
	  phiD_chir_cont.data[iboot]=fun_fit_phiD(A[iboot],B[iboot],C[iboot],ml_phys[iboot],0);
	  phiD_chir[ib].data[iboot]=fun_fit_phiD(A[iboot],B[iboot],C[iboot],ml_phys[iboot],lat[ib][iboot]);
	  
	  if(r!=-1) phiD_estr_ml.data[ib].data[iboot]=phiD[r][iboot]*fun_fit_phiD(A[iboot],B[iboot],C[iboot],ml_phys[iboot],0)/fun_fit_phiD(A[iboot],B[iboot],C[iboot],ml[r][iboot],0);
	}
    }
  boot temp(nboot,njack);
  temp.load("../chiral_cont_extrapol_M/MD");
  cout<<"Using for MD_phys the value: "<<temp<<endl;
  boot fD_chir_cont=phiD_chir_cont/sqrt(temp);
  
  for(int iens=0;iens<nens;iens++)
    cout<<(ml[iens]*db0).med()<<" "<<lat[ibeta[iens]].med()<<" "<<phiD[iens]<<endl;
  
  //chiral and continuum
  cout<<"phiD = ("<<phiD_chir_cont*1000<<") MeV"<<endl;
  cout<<"fD = ("<<fD_chir_cont*1000<<") MeV"<<endl;
  phiD_chir_cont.write_to_binfile("results_phiD");
  fD_chir_cont.write_to_binfile("results_fD");
  
  par_res_fit_phiD=bvec(3,nboot,njack);
  
  par_res_fit_phiD.data[0]=A;
  par_res_fit_phiD.data[1]=B;
  par_res_fit_phiD.data[2]=C;
  
  const char tag_ml[1024]="m\\sl\\N\\SMS,2GeV\\N (GeV)";
  const char tag_a2[1024]="a\\S2\\N (fm)";
  double lat_med_fm[4]={lat[0].med()/hc,lat[1].med()/hc,lat[2].med()/hc,lat[3].med()/hc};
  plot_funz_ml("phiD_funz_ml.xmg",meson_name,tag_ml,meson_name,ml,phiD,par_res_fit_phiD,ml_phys.med(),fun_fit_phiD,phiD_chir_cont);
  plot_funz_a2("phiD_funz_a2.xmg",meson_name,tag_a2,meson_name,lat_med_fm,phiD_estr_ml,par_res_fit_phiD,fun_fit_phiD,phiD_chir_cont);
  
  cout<<lat[0]<<endl;
  cout<<lat[1]<<endl;
  cout<<lat[2]<<endl;
  cout<<lat[3]<<endl;
  
  return 0;
}
예제 #12
0
파일: extr.cpp 프로젝트: sunpho84/sunpho
int main(int narg,char **arg)
{
  init_latpars();
  
  //read ensemble list, meson masses and meson name
  FILE *an_input_file=open_file("analysis_pars","r");
  char meson_name[1024];
  read_formatted_from_file_expecting((char*)&include_a4,an_input_file,"%d","include_a4");
  read_formatted_from_file_expecting((char*)&include_380,an_input_file,"%d","include_380");
  read_formatted_from_file_expecting((char*)&include_ml_term,an_input_file,"%d","include_ml_term");
  read_formatted_from_file_expecting((char*)&nens,an_input_file,"%d","nens");
  read_formatted_from_file_expecting(meson_name,an_input_file,"%s","meson_name");
  read_formatted_from_file_expecting((char*)&dimension,an_input_file,"%d","dimension");
  lmass=new double[nens];
  ibeta=new int[nens];
  F=bvec(nens,nboot,njack);
  
  ofstream bare_data_table("bare_data_table");
  ofstream dim_data_table("dim_data_table");
  
  for(int iens=0;iens<nens;iens++)
    {
      char path[1024];
      read_formatted_from_file((char*)&(ibeta[iens]),an_input_file,"%d","ibeta");
      read_formatted_from_file((char*)&(lmass[iens]),an_input_file,"%lg","lmass");
      read_formatted_from_file(path,an_input_file,"%s","path");
      
      jack temp(njack);
      temp.load(combine("../%s/%s",path,meson_name).c_str());
      
      //write the bare data table
      bare_data_table<<iens<<" "<<smart_print(temp)<<endl;
      
      //load iboot
      int iboot_jack[100];
      load_iboot(iboot_jack,path);
      
      boot_from_jack(F.data[iens],temp,iboot_jack);
      F[iens]/=pow(lat[ibeta[iens]],dimension);

      //write the dimensional data table
      dim_data_table<<iens<<" "<<smart_print(F[iens])<<endl;
    }
  fclose(an_input_file);
  
  //define ml and ref ml
  ml=bvec(nens,nboot,njack);
  for(int iens=0;iens<nens;iens++)
    {
      int b=ibeta[iens],r=ref_ml_beta[b];
      //define ml
      cout<<iens<<" "<<b<<" "<<lmass[iens]<<endl;
      ml[iens]=lmass[iens]/lat[b]/Zp[b];
      //set the lighter mass
      if(r==-1||fabs(ml[r].med()-0.050)>fabs(ml[iens].med()-0.050)) ref_ml_beta[b]=iens;
    }
  cout<<"---"<<endl;
  for(int ib=0;ib<nbeta;ib++) if(ref_ml_beta[ib]!=-1) cout<<"Ref "<<ib<<" = "<<ref_ml_beta[ib]<<", "<<ml[ref_ml_beta[ib]]<<" MeV"<<endl;
  cout<<"---"<<endl;

  //perform the fit
  boot A(nboot,njack),B(nboot,njack),C(nboot,njack),D(nboot,njack);
  fit(A,B,C,D,ml,F);
  
  //chiral extrapolation
  bvec F_chir(nbeta,nboot,njack);
  boot F_chir_cont(nboot,njack);
  bvec F_estr_ml(nbeta,nboot,njack);
  for(int iboot=0;iboot<nboot+1;iboot++)
    {
      F_chir_cont.data[iboot]=fun_fit_F(A[iboot],B[iboot],C[iboot],D[iboot],ml_phys[iboot],0);
      for(int ib=0;ib<nbeta;ib++)
	{
	  int r=ref_ml_beta[ib];
	  F_chir[ib].data[iboot]=fun_fit_F(A[iboot],B[iboot],C[iboot],D[iboot],ml_phys[iboot],lat[ib][iboot]);
	  if(r!=-1)
	    F_estr_ml.data[ib].data[iboot]=F[r][iboot]*fun_fit_F(A[nboot],B[nboot],C[nboot],D[nboot],ml_phys[nboot],0)/fun_fit_F(A[nboot],B[nboot],C[nboot],D[nboot],ml[r][nboot],0);
	}
    }
  
  //chiral and continuum
  cout<<"F = "<<smart_print(F_chir_cont)<<" GeV^"<<dimension<<endl;
  cout<<endl;
  
  par_res_fit_F=bvec(4,nboot,njack);
  
  par_res_fit_F.data[0]=A;
  par_res_fit_F.data[1]=B;
  par_res_fit_F.data[2]=C;
  par_res_fit_F.data[3]=D;
  
  const char tag_ml[1024]="m\\sl\\N\\SMS,2GeV\\N (GeV)";
  const char tag_a2[1024]="a\\S2\\N (fm)";
  double lat_med_fm[4]={lat[0].med()*hc,lat[1].med()*hc,lat[2].med()*hc,lat[3].med()*hc};
  
  plot_funz_ml("F_funz_ml.xmg",meson_name,tag_ml,meson_name,ml,F,par_res_fit_F,ml_phys.med(),fun_fit_F,F_chir_cont);
  plot_funz_a2("F_funz_a2.xmg",meson_name,tag_a2,meson_name,lat_med_fm,F_estr_ml,par_res_fit_F,fun_fit_F,F_chir_cont);

  F_chir_cont.write_to_binfile("results");
  
  return 0;
}
예제 #13
0
extern void particle_textcopy(const vec &s, const char *t, int type, int fade = 2000, int color = 0xFFFFFF, float size = 2.0f, int gravity = 0);
extern void particle_icon(const vec &s, int ix, int iy, int type, int fade = 2000, int color = 0xFFFFFF, float size = 2.0f, int gravity = 0);
extern void particle_meter(const vec &s, float val, int type, int fade = 1, int color = 0xFFFFFF, int color2 = 0xFFFFF, float size = 2.0f);
extern void particle_flare(const vec &p, const vec &dest, int fade, int type, int color = 0xFFFFFF, float size = 0.28f, physent *owner = NULL);
extern void particle_fireball(const vec &dest, float max, int type, int fade = -1, int color = 0xFFFFFF, float size = 4.0f);
extern void removetrackedparticles(physent *owner = NULL);

// decal
enum
{
    DECAL_SCORCH = 0,
    DECAL_BLOOD,
    DECAL_BULLET
};

extern void adddecal(int type, const vec &center, const vec &surface, float radius, const bvec &color = bvec(0xFF, 0xFF, 0xFF), int info = 0);

// worldio
extern bool load_world(const char *mname, const char *cname = NULL);
extern bool save_world(const char *mname, bool nolms = false);
extern void getmapfilename(const char *fname, const char *cname, char *mapname);
extern uint getmapcrc();
extern void clearmapcrc();
extern bool loadents(const char *fname, vector<entity> &ents, uint *crc = NULL);

// physics
extern vec collidewall;
extern bool collideinside;
extern physent *collideplayer;

extern void moveplayer(physent *pl, int moveres, bool local);
예제 #14
0
//stack[sp] is current color index
static void text_color(char c, char *stack, int size, int &sp, bvec color, int a)
{
    if(c=='s') // save color
    {
        c = stack[sp];
        if(sp<size-1) stack[++sp] = c;
    }
    else
    {
        if(c=='r') c = stack[(sp > 0) ? --sp : sp]; // restore color
        else if(c == 'b') { if(allowblinkingtext && !ignoreblinkingbit) stack[sp] *= -1; } // blinking text - only if allowed
        else stack[sp] = c;
        switch(abs(static_cast<int>(stack[sp])))
        {
            case '0': color = bvec( 2,  255,  128 ); break;   // green: player talk
            case '1': color = bvec( 96,  160, 255 ); break;   // blue: team chat
            case '2': color = bvec( 255, 192,  64 ); break;   // yellow: gameplay action messages, only actions done by players - 230 230 20 too bright
            case '3': color = bvec( 255,  64,  64 ); break;   // red: important errors and notes
            case '4': color = bvec( 128, 128, 128 ); break;   // gray
            case '5': color = bvec( 255, 255, 255 ); break;   // white
            case '6': color = bvec(  96,  48,   0 ); break;   // dark brown
            case '7': color = bvec( 153,  51,  51 ); break;   // dark red: dead admin
            case '8': color = bvec( 192,  64, 192 ); break;   // magenta
            case '9': color = bvec( 255, 102,   0 ); break;   // orange

            case 'm': color = bvec(   0, 116,  57 ); break;   // dark green: dead master
            case 'o': color = bvec(  31,  86, 166 ); break;   // dark blue: dead 'owner'

            //extendeded color palette
            //case 'a': case 'A':color = bvec( 0xFF, 0xCC, 0xCC); break;   // some lowercase seem to have special meaning like 'b' (flashing text) so not yet using them
            case 'A':color = bvec( 0xff, 0xb7, 0xb7); break;   // red set
            case 'B':color = bvec( 0xCC, 0x33, 0x33); break;   //
            case 'C':color = bvec( 0x66, 0x33, 0x33); break;   //
            case 'D':color = bvec( 0xF8, 0x98, 0x4E); break;   //

            case 'E':color = bvec( 0xFF, 0xFF, 0xB7); break;   // yellow set
            case 'F':color = bvec( 0xCC, 0xCC, 0x33); break;   //
            case 'G':color = bvec( 0x66, 0x66, 0x33); break;   //
            case 'H':color = bvec( 0xCC, 0xFC, 0x58); break;   //

            case 'I':color = bvec( 0xB7, 0xFF, 0xB7); break;   // green set
            case 'J':color = bvec( 0x33, 0xCC, 0x33); break;   //
            case 'K':color = bvec( 0x33, 0x66, 0x33); break;   //
            case 'L':color = bvec( 0x3F, 0xFF, 0x98); break;   //

            case 'M':color = bvec( 0xB7, 0xFF, 0xFF); break;   // cyan set
            case 'N':color = bvec( 0x33, 0xCC, 0xCC); break;   //
            case 'O':color = bvec( 0x33, 0x66, 0x66); break;   //
            case 'P':color = bvec( 0x4F, 0xCC, 0xF8); break;   //

            case 'Q':color = bvec( 0xB7, 0xB7, 0xFF); break;   // blue set
            case 'R':color = bvec( 0x33, 0x33, 0xCC); break;   //
            case 'S':color = bvec( 0x33, 0x33, 0x66); break;   //
            case 'T':color = bvec( 0xA0, 0x49, 0xFF); break;   //

            case 'U':color = bvec( 0xFF, 0xB7, 0xFF); break;   // magenta set
            case 'V':color = bvec( 0xCC, 0x33, 0xCC); break;   //
            case 'W':color = bvec( 0x66, 0x33, 0x66); break;   //
            case 'X':color = bvec( 0xFF, 0x01, 0xD5); break;   //

            case 'Y':color = bvec( 0xC7, 0xD1, 0xE2); break;   // lt gray
            case 'Z':color = bvec( 0x32, 0x32, 0x32); break;   // dark gray
            // white (provided color): everything else
            //default: color = bvec( 255, 255, 255 ); break;
        }
        if (stack[sp] <= 0)
            a = min(abs((int) (a * sinf(lastmillis / 200.0f) * 1.15f)), 100);
        glColor4ub(color.x, color.y, color.z, a);
    }
}
예제 #15
0
int main(int narg,char **arg)
{
  if(narg<2)
    {
      fprintf(stderr,"Error, use: %s file\n",arg[0]);
      exit(1);
    }
  
  grace out("fit_xmax.xmg");
  FILE *fin=open_file(arg[1],"r");
  const char color[3][1024]={"blue","green","red"};
  int nmu;
  read_formatted_from_file_expecting((char*)&nmu,fin,"%d","nmu");

  double muI[nmu],muI2[nmu];
  bvec xmax[3];xmax[0]=xmax[1]=xmax[2]=bvec(nmu,99,2);
  for(int imu=0;imu<nmu;imu++)
    {
      char path[1024];
      read_formatted_from_file((char*)&(muI[imu]),fin,"%lg","path");
      read_formatted_from_file(path,fin,"%s","path");
      for(int det=0;det<3;det++) xmax[det][imu]=get_xmax(path,det);
      muI2[imu]=sqr(muI[imu]);
      if(muI[imu]<0) muI2[imu]*=-1;
    }
  
  for(int det=0;det<3;det++)
    {
      bvec par_fit4=poly_fit(muI2,xmax[det],2);
      bvec par_fit6=poly_fit(muI2,xmax[det],3);
      bvec par_fitR=rat21_fit(par_fit4,muI2,xmax[det]);
      
      cout<<chi2_pol(par_fit4,muI2,xmax[det])/(nmu-3)<<endl;
      cout<<chi2_pol(par_fit6,muI2,xmax[det])/(nmu-4)<<endl;
      {
	double p[4]={par_fitR[0][nboot],par_fitR[1][nboot],par_fitR[2][nboot],par_fitR[3][nboot]};
	cout<<chi2_rat21(p)/(nmu-4)<<endl;
      }
      
      int nfit=300;
      double mu2F[nfit+1],mu2F_min=-0.5,mu2F_max=muI2[nmu-1];
      
      bvec xmaxF4(nfit+1,99,2);
      bvec xmaxF6(nfit+1,99,2);
      bvec xmaxFR(nfit+1,99,2);
      for(int ifit=0;ifit<=nfit;ifit++)
	{
	  double x=mu2F[ifit]=mu2F_min+(mu2F_max-mu2F_min)/nfit*ifit;
	  xmaxF4[ifit]=pol(par_fit4,x);
	  xmaxF6[ifit]=pol(par_fit6,x);
	  for(int iboot=0;iboot<=nboot;iboot++)
	    {
	      double p[4]={par_fitR[0][iboot],par_fitR[1][iboot],par_fitR[2][iboot],par_fitR[3][iboot]};
	      xmaxFR[ifit].data[iboot]=ratfun21(x,p);
	    }
	}
      
      out.set(2,"none","square");
      out.print_graph(muI2,xmax[det]);
      out.new_set();
      out.set(1,color[det]);
      out.polygon(mu2F,xmaxF4);
      out.new_set();
      out.set(1,color[det]);
      out.polygon(mu2F,xmaxF6);
      out.new_set();
      out.set(1,color[det]);
      out.polygon(mu2F,xmaxFR);
      out.new_set();
      
      cout<<par_fit4[1]<<endl;
      cout<<par_fit6[1]<<endl;
      cout<<par_fitR[1]-par_fitR[3]*par_fitR[0]<<endl;
    }
  
  return 0;
}
예제 #16
0
bvec Reed_Solomon::decode(const vec &)
{
  it_error("Reed_Solomon::decode(): Soft-decision decoding not implemented");
  return bvec();
}
예제 #17
0
 //-----------------------------------------------------------------------
 //                   s e t L i n e a r V e l o c i t y
 //-----------------------------------------------------------------------
 void TPhysicsObject::setLinearVelocity(const TVector3& value)
 {
     btVector3 bvec(value.X, value.Y, value.Z);
     m_rigidBody->setLinearVelocity(bvec);
 }
예제 #18
0
bvec Hamming_Code::decode(const vec &)
{
    it_error("Hamming_Code::decode(vec, bvec); soft-decision decoding is not implemented");
    return bvec();
}
예제 #19
0
파일: lcp.cpp 프로젝트: order/lcp-research
PLCP augment_plcp(const PLCP & original,
                  vec & x,
                  vec & y,
                  vec & w,
                  double scale){
  
  uint N = original.P.n_rows;
  uint K = original.P.n_cols;
  assert(size(K,N) == size(original.U));

  
  sp_mat P = sp_mat(original.P);
  double I_norm = norm(speye(K,K) - P.t() * P);
  if(norm(I_norm) >= PRETTY_SMALL){
    cerr << "Error: P does not look orthogonal ("
	 << I_norm << ")..." << endl;
  }
  assert(I_norm < PRETTY_SMALL);
  
  sp_mat U = sp_mat(original.U);
  vec q = vec(original.q);
  assert(all(q(find(1 == original.free_vars)) <= 0));


  vec q_neg = min(zeros<vec>(N),q);
  vec q_pos = max(zeros<vec>(N),q);
  x = ones<vec>(N) - q_neg;
  y = ones<vec>(N) + q_pos;
  y(find(1 == original.free_vars)).fill(0);
  assert(norm(q_pos(find(1 == original.free_vars))) < ALMOST_ZERO);
  
  assert(N == x.n_elem);
  assert(N == y.n_elem);
  assert(all(x >= 0));
  assert(all(y >= 0));

  vec res = x - y + q;
  w = spsolve(P.t()*P + 1e-15*speye(K,K),P.t()*(x - y + q));

  vec w_res = P * w - res;
  if(norm(w_res) >= PRETTY_SMALL){
    cerr << "Error: Reduced vector w residual large ("
	 << w_res << ")..." << endl;
  }

  assert(norm(w_res) < PRETTY_SMALL);
  
  vec b = P.t()*x - U*x - w;
  assert(K == b.n_elem);
  
  P.resize(N+1,K+1);
  U.resize(K+1,N+1);
  q.resize(N+1);
  
  P(N,K) = 1.0;
  U(span(0,K-1),N) = b;
  U(K,N) = scale;
  q(N) = 0;

  x.resize(N+1);
  y.resize(N+1);
  w.resize(K+1);

  x(N) = 1;
  y(N) = scale;
  w(K) = 1.0 - scale;
  
  bvec free_vars = bvec(N+1);
  free_vars.head(N) = original.free_vars;
  free_vars(N) = 0;
  
  return PLCP(P,U,q,free_vars);
}