Esempio n. 1
0
int main() {
    seed = time(NULL);
    float prob[TOTAL_SIZE];
    int iter;
    float avg = 1;
    float current;
    int counter;
    int if_continue = 1;
    buffer_size = 41;

    avg = 0;
    for(iter=0; iter<TOTAL_SIZE; ++iter) {
        sim_init();
        current = run();
        avg += current;

        buffer_size /= 1024;
        prob[iter] = current;
    }
    printf("%d %.6f %0.6f\n", buffer_size, avg/100,
           1.96*sdv(prob, avg/100, TOTAL_SIZE)/sqrt(TOTAL_SIZE));



    return 0;
}
Esempio n. 2
0
void MetadataItem::setDescription(const wxString& description)
{
    if (getDescription() != description)
    {
        SaveDescriptionVisitor sdv(description);
        acceptVisitor(&sdv);
        // if previous statement didn't throw the description has been saved
        descriptionLoadedM = lsLoaded;
        descriptionM = description;
        // call notifyObservers(), because this is only called after
        // the description has been edited by the user
        notifyObservers();
    }
}
Esempio n. 3
0
void CameraScreen::reinit() {
	Camera::reinit();
	// find the position of the center of the screen in 3D space
	this->centerScreen = position + (screenDist * direction);
	double cosrot = cos(rotation);
	double sinrot = sin(rotation);
	// compute the directions of the u and v vector along the screen
	P3S sDir(direction);
	P3S sdu(P3(cosrot,0.0,sinrot));
	P3S sdv(P3(sinrot,0.0,cosrot));
	sdu.u += sDir.u + M_PI/2;
	sdv.v += sDir.v;
	P3 du(sdu);
	P3 dv(sdv);
	du.normalize();
	dv.normalize();
	// deduce dx and dy
	this->dx = du;
	this->dy = - dv;
	// precompute the top left corner of the screen
	int width = screen->getWidth();
	int height = screen->getHeight();
	this->topLeftCornerScreen = centerScreen - ((width/2)*dx) - ((height/2)*dy);
}
Esempio n. 4
0
void
Stokhos::PseudoSpectralOrthogPolyExpansion<ordinal_type, value_type, point_compare_type, node_type>::
nary_op(const FuncT& func,
	OrthogPolyApprox<ordinal_type, value_type, node_type>& c, 
	const OrthogPolyApprox<ordinal_type, value_type, node_type>** na)
{
  const int N = FuncT::N;
  bool is_constant = true;
  for (int i=0; i<N; i++) {
    if (na[i]->size() > 1) {
      is_constant = false;
      break;
    }
  }
  ordinal_type pc;
  if (is_constant)
    pc = 1;
  else
    pc = sz;
  if (c.size() != pc)
    c.resize(pc);

  if (pc == 1) {
    value_type val[N];
    for (int i=0; i<N; i++)
      val[i] = (*na[i])[0];
    c[0] = func(val);
    return;
  }

  if (N >= navals.size())
    navals.resize(N+1);
  if (navals[N].size() != N) {
    navals[N].resize(N);
    for (int i=0; i<N; i++)
      navals[N][i].resize(nqp);
  }
  
  {
#ifdef STOKHOS_TEUCHOS_TIME_MONITOR
  TEUCHOS_FUNC_TIME_MONITOR("Stokhos::PSExp -- N(" << N << ")-ary Polynomial Evaluation");
#endif

  // Evaluate input
  for (int i=0; i<N; i++) {
    SDV sdv(Teuchos::View, const_cast<value_type*>(na[i]->coeff()), 
	    na[i]->size());
    ps_op->transformPCE2QP(1.0, sdv, navals[N][i], 0.0, false);
  }

  }

  {
#ifdef STOKHOS_TEUCHOS_TIME_MONITOR
  TEUCHOS_FUNC_TIME_MONITOR("Stokhos::PSExp -- N(" << N << ")-ary Function Evaluation");
#endif

  // Evaluate function
  value_type val[N];
  for (ordinal_type qp=0; qp<nqp; qp++) {
    for (int i=0; i<N; i++)
      val[i] = navals[N][i][qp];
    fvals[qp] = func(val);
  }

  }

  {
#ifdef STOKHOS_TEUCHOS_TIME_MONITOR
  TEUCHOS_FUNC_TIME_MONITOR("Stokhos::PSExp -- N(" << N << ")-ary Polynomial Integration");
#endif

  // Integrate
  SDV c_sdv(Teuchos::View, c.coeff(), pc);
  ps_op->transformQP2PCE(1.0, fvals, c_sdv, 0.0, false);

  }
}