Пример #1
0
//___________________________________________________________________________________________
void KVValues::init_val_base()
{
//protected method
//Mise en correspondance du noms des differentes valeurs a calculees
//et de leur position dans le tableau values
// Ex:
// nom_valeurs -> id_valeurs -> values[id_valeurs]

   KVString lname = "MIN MAX";
   lname.Begin(" ");
   kval_base = 0;    //variables de base disponibles

   kval_tot = 0; //nombre de variables totales disponibles
   while (!lname.End()) {
      KVString tamp = lname.Next();
      SetValue(tamp.Data(), kval_tot++);
   }
   kdeb = kval_tot;  //ici pos_deb=2 (par defaut)

   KVString smoment;
   for (Int_t mm = 0; mm <= kordre_mom_max; mm += 1) { //Ex: moment_max = 3
      smoment.Form("SUM%d", mm);
      SetValue(smoment.Data(), kval_tot++);
   }
   kval_base = kval_tot;   //ici nbase=6 (par defaut)

   values = new Double_t[knbre_val_max];
   init_val();


}
Пример #2
0
int			main(void)
{
	t_bal		bal;
	t_brick		brick;
	t_env		e;

	init_env(&e);
	ft_singleton(&e);
	init_val(&bal);
	e.map = get_map("level/level1.txt");
	e.curr_map = 1;
	init_window(&e);
	glfwSetKeyCallback(e.window, key_callback);
	glfwGetFramebufferSize(e.window, &e.width, &e.height);
	glClearColor(0.f, 0.f, 0.f, 0.0f);
	boucle_principal(&bal, &brick, &e);
	glfwTerminate();
	return (0);
}
Пример #3
0
// [[Rcpp::export]]
Rcpp::List TOUCH_FUNS(Rcpp::NumericVector lparam, Rcpp::NumericVector linit,
		      SEXP xifun, SEXP xtfun, SEXP xdfun) {


  int i;

  Rcpp::List ans;

  Rodeproblem *prob  = new Rodeproblem(lparam, linit);

  prob->Rodeproblem::init_fun(xifun);
  prob->Rodeproblem::table_fun(xtfun);

  double time = 0;
  prob->time(time);
  prob->newind(0);

  prob->init_call(time);
  prob->table_init_call();

  std::vector<std::string> tablenames;
  const sd_map& Tabledata = prob->table();
  for(tablemap::const_iterator it=Tabledata.begin(); it !=Tabledata.end(); ++it) {
    tablenames.push_back(it->first);
  }

  const dvec& init = prob->init();

  Rcpp::NumericVector init_val(prob->neq());

  for(i=0; i < (prob->neq()); i++) init_val[i] = init[i];

  ans["tnames"] = tablenames;
  ans["init"] = init_val;
  ans["npar"] = prob->npar();
  ans["neq"] = prob->neq();
  delete prob;
  return(ans);
}
Пример #4
0
static void
opt_blks(struct block *root, int do_stmts)
{
	int i, maxlevel;
	struct block *p;

	init_val();
	maxlevel = root->level;

	find_inedges(root);
	for (i = maxlevel; i >= 0; --i)
		for (p = levels[i]; p; p = p->link)
			opt_blk(p, do_stmts);

	if (do_stmts)
		/*
		 * No point trying to move branches; it can't possibly
		 * make a difference at this point.
		 */
		return;

	for (i = 1; i <= maxlevel; ++i) {
		for (p = levels[i]; p; p = p->link) {
			opt_j(&p->et);
			opt_j(&p->ef);
		}
	}

	find_inedges(root);
	for (i = 1; i <= maxlevel; ++i) {
		for (p = levels[i]; p; p = p->link) {
			or_pullup(p);
			and_pullup(p);
		}
	}
}
Пример #5
0
//___________________________________________________________________________________________
void KVValues::Reset()
{

   init_val();
   kToBeRecalculated = kTRUE;
}
Пример #6
0
int main() {

  std::vector<double> positions;
  std::vector<double> measurements;
  std::vector<double> var;
  double nmeas = 0;

#ifdef USE_SEALBASE
  seal::Filename   inputFile (seal::Filename ("$SEAL/src/MathLibs/Minuit/tests/MnSim/paul2.txt").substitute (seal::ShellEnvironment ()));
  std::ifstream in(inputFile.name() );
#else
  std::ifstream in("paul2.txt");
#endif
  if (!in) {
    std::cerr << "Error opening input data file" << std::endl;
    return 1; 
  }


  // read input data
  {
    double x = 0., y = 0., width = 0., err = 0., un1 = 0., un2 = 0.;
    while(in>>x>>y>>width>>err>>un1>>un2) {
      if(err < 1.e-8) continue;
      positions.push_back(x);
      measurements.push_back(y);
      var.push_back(err*err);
      nmeas += y;
    }
    std::cout<<"size= "<<var.size()<<std::endl;
    assert(var.size() > 0);
    std::cout<<"nmeas: "<<nmeas<<std::endl;
  }

  // create FCN function  
  GaussFcn theFCN(measurements, positions, var);

  std::vector<double> meas = theFCN.measurements();
  std::vector<double> pos = theFCN.positions();

  // create initial starting values for parameters
  double x = 0.;
  double x2 = 0.;
  double norm = 0.;
  double area = 0.;
  double dx = pos[1]-pos[0];
  for(unsigned int i = 0; i < meas.size(); i++) {
    norm += meas[i];
    x += (meas[i]*pos[i]);
    x2 += (meas[i]*pos[i]*pos[i]);
    area += dx*meas[i];
  }
  double mean = x/norm;
  double rms2 = x2/norm - mean*mean;

  std::cout<<"initial mean: "<<mean<<std::endl;
  std::cout<<"initial sigma: "<<sqrt(rms2)<<std::endl;
  std::cout<<"initial area: "<<area<<std::endl;
  std::vector<double> init_val(3);
  init_val[0] = mean;
  init_val[1] = sqrt(rms2);
  init_val[2] = area; 
  std::cout<<"initial fval: "<<theFCN(init_val)<<std::endl;
  
  MnUserParameters upar;
  upar.add("mean", mean, 1.);
  upar.add("sigma", sqrt(rms2), 1.);
  upar.add("area", area, 10.);

  MnMigrad migrad(theFCN, upar);
  std::cout<<"start migrad "<<std::endl;
  FunctionMinimum min = migrad();
  std::cout<<"minimum: "<<min<<std::endl;

  std::cout<<"start minos"<<std::endl;
  MnMinos minos(theFCN, min);
  std::pair<double,double> e0 = minos(0);
  std::pair<double,double> e1 = minos(1);
  std::pair<double,double> e2 = minos(2);
  
  std::cout<<"par0: "<<min.userState().value("mean")<<" "<<e0.first<<" "<<e0.second<<std::endl;
  std::cout<<"par1: "<<min.userState().value(1)<<" "<<e1.first<<" "<<e1.second<<std::endl;
  std::cout<<"par2: "<<min.userState().value(2)<<" "<<e2.first<<" "<<e2.second<<std::endl;

  return 0;
}
Пример #7
0
int
main (void)
{
  {
    __v2si val;
    __v2si val2;
    __v2si val3;

    init_val(&val);

    /* Copy val to val2.  */
    vector_store (&val2, val);

    /* Copy val2 to val3.  */
    val3 = vector_load (&val2);

    /* Compare val to val3.  */
    {
      char *p = (char*)&val;
      char *p2 = (char*)&val3;

      if (p[0] != p2[0])
	return 1;
      if (p[1] != p2[1])
	return 1;
      if (p[2] != p2[2])
	return 1;
      if (p[3] != p2[3])
	return 1;
      if (p[4] != p2[4])
	return 1;
      if (p[5] != p2[5])
	return 1;
      if (p[6] != p2[6])
	return 1;
      if (p[7] != p2[7])
	return 1;
    }
  }

  {
    __v2si val4 = vector_const ();
    char *p = (char*)&val4;

    if (p[0] != 1)
      return 1;
    if (p[1] != 0)
      return 1;
    if (p[2] != 0)
      return 1;
    if (p[3] != 0)
      return 1;
    if (p[4] != 2)
      return 1;
    if (p[5] != 0)
      return 1;
    if (p[6] != 0)
      return 1;
    if (p[7] != 0)
      return 1;
  }

  return 0;
}