void Utility::Yuv422FileSaver::savePlanar() {
	for(std::size_t k=0; k<video_->getNumberOfFrames()&&isRunning_; k++) {
		QVector<unsigned char> uBuffer;
		QVector<unsigned char> vBuffer;
		auto frame=video_->getFrame(k);
		for(int i=0; i<width_*height_; i+=2) {
			int y1=i/width_;
			int x1=i%width_;
			int y2=(i+1)/width_;
			int x2=(i+1)%width_;

			if(!frame->valid(x1,y1)||!frame->valid(x2,y2)) {
				qDebug()<<"Wrong pixel coordinates";
				continue;
			}

			auto vec=Rgb888ToYuv422(frame->pixel(x1,y1),frame->pixel(x2,y2));
			dataStream_<<vec.getY1()<<vec.getY2();
			uBuffer.push_back(vec.getU());
			vBuffer.push_back(vec.getV());
		}
		while (!uBuffer.isEmpty()) {
			dataStream_<<uBuffer.takeFirst();
		}
		while (!vBuffer.isEmpty()) {
			dataStream_<<vBuffer.takeFirst();
		}
	}
}
void TestYuv444FileSaver::testRgb888ToYuv444() {
	auto vector = Utility::Yuv444FileSaver::Rgb888ToYuv444(pixel);
	QVERIFY(vector.getY() == 16);
	QVERIFY(vector.getU() == 128);
	QVERIFY(vector.getV() == 128);

}
Beispiel #3
0
	void transformNormals(const Mat4& transformation){
		const Vec4 u = transformation * getU();
		const Vec4 v = transformation * getV();
		const Vec4 n = transformation * getN();
		setOrientation(u,v,n);
		setPosition(position);
	}
Beispiel #4
0
int GMSH_CutParametricPlugin::fillXYZ()
{
  std::vector<std::string> expressions(3), variables(2);
  for(int i = 0; i < 3; i++)
    expressions[i] = CutParametricOptions_String[i].def;
  variables[0] = "u";
  variables[1] = "v";
  mathEvaluator f(expressions, variables);
  if(expressions.empty()) return 0;

  int nbU = (int)CutParametricOptions_Number[2].def;
  int nbV = (int)CutParametricOptions_Number[5].def;
  x.resize(nbU * nbV);
  y.resize(nbU * nbV);
  z.resize(nbU * nbV);
  std::vector<double> val(2), res(3);
  for(int i = 0; i < nbU; ++i){
    val[0] = getU(i);
    for(int j = 0; j < nbV; ++j){
      val[1] = getV(j);
      if(f.eval(val, res)){
        x[i * nbV + j] = res[0];
        y[i * nbV + j] = res[1];
        z[i * nbV + j] = res[2];
      }
    }
  }
  return 1;
}
Beispiel #5
0
	void setPosition(const Vec4& pos){
		position = pos;
		const Vec4 eyeVector = position - Vec4::origin();
		matrix.cArray[12] = -eyeVector * getU();
		matrix.cArray[13] = -eyeVector * getV();
		matrix.cArray[14] = -eyeVector * getN();
	}
 void computeU(const double *x, int xLen, double *u, int uLen)
 {
   assert(xLen == xDim && uDim == uLen);
   setX(x, xLen);
   computeU();
   getU(u, uLen);
 }
Beispiel #7
0
float BlockHighPass::update(float input)
{
	float b = 2 * float(M_PI) * getFCut() * getDt();
	float a = 1 / (1 + b);
	setY(a * (getY() + input - getU()));
	setU(input);
	return getY();
}
Beispiel #8
0
float BlockIntegralTrap::update(float input)
{
	// trapezoidal integration
	setY(_limit.update(getY() +
			   (getU() + input) / 2.0f * getDt()));
	setU(input);
	return getY();
}
void TestYuv411FileSaver::testRgb888ToYuv411() {
	auto vector = Utility::Yuv411FileSaver::Rgb888ToYuv411(pixel1,pixel2,pixel3,pixel4);
	QVERIFY(vector.getY1() == 16);
	QVERIFY(vector.getU() == 128);
	QVERIFY(vector.getV() == 128);
	QVERIFY(vector.getY2() == 16);
	QVERIFY(vector.getY3() == 16);
	QVERIFY(vector.getY4() == 16);
}
Beispiel #10
0
peano::applications::faxen::records::RegularGridCell peano::applications::faxen::records::RegularGridCellPacked::convert() const{
   return RegularGridCell(
      getP(),
      getU(),
      getV(),
      getF(),
      getG(),
      getRhs(),
      getRes(),
      getIsInside()
   );
}
Beispiel #11
0
 bool SymBandSVDiv<T>::checkDecomp(
     const BaseMatrix<T>& m, std::ostream* fout) const
 {
     Matrix<T> mm = m;
     if (fout) {
         *fout << "SymBandSVDiv:\n";
         *fout << "M = "<<mm<<std::endl;
         *fout << "U = "<<getU()<<std::endl;
         *fout << "S = "<<getS()<<std::endl;
         *fout << "Vt = "<<getVt()<<std::endl;
     }
     Matrix<T> usv = getU()*getS()*getVt();
     RT nm = Norm(usv-mm);
     nm /= Norm(getU())*Norm(getS())*Norm(getVt());
     RT cond = condition();
     if (fout) {
         *fout << "USVt = "<<usv<<std::endl;
         *fout << "Norm(M-USVt)/Norm(USVt) = "<<nm;
         *fout <<"  "<<cond<<" * "<<TMV_Epsilon<T>()<<std::endl;
     }
     return nm < cond*RT(mm.colsize())*TMV_Epsilon<T>();
 }
Beispiel #12
0
 bool LUDiv<T>::checkDecomp(const BaseMatrix<T>& m, std::ostream* fout) const
 {
     Matrix<T> mm = m;
     if (fout) {
         *fout << "LUDiv:\n";
         *fout << "M = "<<
             (pimpl->istrans?mm.transpose():mm.view())<<std::endl;
         *fout << "L = "<<getL()<<std::endl;
         *fout << "U = "<<getU()<<std::endl;
         *fout << "P = "<<getP()<<std::endl;
         *fout << "  or by interchanges: ";
         for(ptrdiff_t i=0;i<getP().size();i++)
             *fout<<(getP().getValues())[i]<<" ";
     }
     Matrix<T> lu = getP()*getL()*getU();
     RT nm = Norm(lu-(pimpl->istrans ? mm.transpose() : mm.view()));
     nm /= Norm(getL())*Norm(getU());
     if (fout) {
         *fout << "PLU = "<<lu<<std::endl;
         *fout << "Norm(M-PLU)/Norm(PLU) = "<<nm<<std::endl;
     }
     return nm < mm.doCondition()*RT(mm.colsize())*TMV_Epsilon<T>();
 }
Beispiel #13
0
void gameEnv::checkIdenticals()
{
	int i = 0;
	int j = 1;
	for(i;i<(n-1);i++)
	{
		for(j;j<n;j++)
		{
			int uToTest = 0;
			int errCount = 0;
			for(uToTest; uToTest < numU; uToTest++)
			{
				if(getU(i,uToTest) == getU(j,uToTest))
				{
					errCount++;
				}
				if(errCount == (numU-1))
				{
					//ERROR WE FOUND IDENTICAL NODES
	std::cout << "ERROR!!!! IDENTICAL NODES!\n";
	std::cout << "ERROR!!!! IDENTICAL NODES!\n";
	std::cout << "ERROR!!!! IDENTICAL NODES!\n";
	std::cout << "ERROR!!!! IDENTICAL NODES!\n";
	std::cout << "ERROR!!!! IDENTICAL NODES!\n";
	std::cout << "ERROR!!!! IDENTICAL NODES!\n";
	std::cout << "ERROR!!!! IDENTICAL NODES!\n";
	std::cout << "ERROR!!!! IDENTICAL NODES!\n";
	std::cout << "ERROR!!!! IDENTICAL NODES!\n";			
				
				}
			}	
		}
	}
	return;

	
}
Beispiel #14
0
returnValue Controller::feedbackStep(	double currentTime,
										const Vector& _y,
										const VariablesGrid& _yRef
										)
{
	realClock.reset( );
	
	if ( controlLaw == 0 )
		return ACADOERROR( RET_NO_CONTROLLAW_SPECIFIED );

	/* Do nothing if controller is disabled */
	if ( isEnabled == BT_FALSE )
		return SUCCESSFUL_RETURN;

	// start real runtime measurement
	realClock.start( );
	
	Vector xEst, pEst;

	/* 1) Call Estimator */
	if ( obtainEstimates( currentTime,_y,xEst,pEst ) != SUCCESSFUL_RETURN )
		return ACADOERROR( RET_CONTROLLER_STEP_FAILED );

	/* 2) Evaluate reference trajectory */
	VariablesGrid yRef( _yRef );
	getCurrentReference( currentTime,yRef );
	#ifdef SIM_DEBUG
	yRef.print( "yRef feedback" );
	#endif

	controlLawClock.reset();
	controlLawClock.start();
	
	/* 3) Perform feedback step of control law */
	if ( controlLaw->feedbackStep( currentTime,xEst,pEst,yRef ) != SUCCESSFUL_RETURN )
		return ACADOERROR( RET_CONTROLLER_STEP_FAILED );

	controlLawClock.stop();
	realClock.stop( );

	#ifdef SIM_DEBUG
	Vector uTmp;
	getU( uTmp );
	uTmp.print("u(0) after feedbackStep");
	#endif

	return SUCCESSFUL_RETURN;
}
void Utility::Yuv444FileSaver::savePacked() {
    for(std::size_t k=0; k<video_->getNumberOfFrames()&&isRunning_; k++) {
        auto frame_=video_->getFrame(k);
        for(int i=0; i<width_*height_; i++) {
            int y1=i/width_;
            int x1=i%width_;

            if(!frame_->valid(x1,y1)) {
                qDebug()<<"Wrong pixel coordinates";
                continue;
            }
            auto vec=Rgb888ToYuv444(frame_->pixel(x1,y1));
            dataStream_<<vec.getY()<<vec.getU()<<vec.getV();
        }
    }
}
Beispiel #16
0
int Pricer::put_american(double &price, double S0, double K, double T, double R, double vol, int N)
{
    if (S0 <= 0 || K <= 0 || vol <= 0 || T <= 0)  {
        //std::cout << "the asset price, the exchange rate, the maturity, the strike and the volatilities must be positive " << std::endl;
        return 10;
    }
    double *PutPayoffs;

    //calcul des valeurs que l'on aura besoin plus tard pour le pricing
    //pas de temps
    const double      h = T / (float)N;
    const double     rh = R * h;
    //facteurs d'actualisation et de capitalisation
    const double      If = exp(rh);
    const double      Df = exp(-rh);
    //pseudo-probabilites
    const double       u = getU(T, vol, N);
    const double       d = getD(T, vol, N);
    const double      pu = (If - d) / (u - d);
    const double      pd = 1.0 - pu;
    const double  puByDf = pu * Df;
    const double  pdByDf = pd * Df;

    double x;
    double s;
    double payoff;
    int i, j;

    //calcul des payoffs a maturite
    PutPayoffs = expiryPutValues(S0, K, N, u, d);

    //descente dans l'arbre
    for (i = N - 1; i >= 0; i--) {
        for (j = 0; j <= i; j++) {
            x = puByDf * PutPayoffs[j] + pdByDf * PutPayoffs[j + 1];
            s = S0 * pow(u, i - j) * pow(d, j);
            payoff = K - s;
            payoff = (payoff>0) ? payoff : 0;
            PutPayoffs[j] = (payoff>x) ? payoff : x;
        }
    }

    //le prix en 0 est stocke a la premiere position du tableau
    price = (double)PutPayoffs[0];
    free(PutPayoffs);
    return 0;
}
Beispiel #17
0
void peano::applications::faxen::records::RegularGridCellPacked::toString (std::ostream& out) const {
   out << "("; 
   out << "P:" << getP();
   out << ",";
   out << "U:" << getU();
   out << ",";
   out << "V:" << getV();
   out << ",";
   out << "F:" << getF();
   out << ",";
   out << "G:" << getG();
   out << ",";
   out << "rhs:" << getRhs();
   out << ",";
   out << "res:" << getRes();
   out << ",";
   out << "isInside:" << getIsInside();
   out <<  ")";
}
Beispiel #18
0
float BlockDerivative::update(float input)
{
	float output;

	if (_initialized) {
		output = _lowPass.update((input - getU()) / getDt());

	} else {
		// if this is the first call to update
		// we have no valid derivative
		// and so we use the assumption the
		// input value is not changing much,
		// which is the best we can do here.
		output = 0.0f;
		_initialized = true;
	}

	setU(input);
	return output;
}
Beispiel #19
0
returnValue Controller::preparationStep(	double nextTime,
											const VariablesGrid& _yRef
											)
{
	if ( controlLaw == 0 )
		return ACADOERROR( RET_NO_CONTROLLAW_SPECIFIED );

	/* Do nothing if controller is disabled */
	if ( isEnabled == BT_FALSE )
		return SUCCESSFUL_RETURN;

	realClock.start();
	controlLawClock.start();

	/* 1) Evaluate reference trajectory */
	VariablesGrid yRef( _yRef );
	getCurrentReference( nextTime,yRef );
	#ifdef SIM_DEBUG
	yRef.print( "yRef preparation" );
	#endif

	/* 2) Perform preparation step of control law */
	if ( controlLaw->preparationStep( nextTime,yRef ) != SUCCESSFUL_RETURN )
		return ACADOERROR( RET_CONTROLLER_STEP_FAILED );

	controlLawClock.stop();
	logCollection.setLast( LOG_TIME_CONTROL_LAW,controlLawClock.getTime() );
	
	// stop real runtime measurement
	realClock.stop();
	logCollection.setLast( LOG_TIME_CONTROLLER,realClock.getTime() );


	#ifdef SIM_DEBUG
	Vector uTmp;
	getU( uTmp );
	uTmp.print("u(0) after preparationStep");
	#endif

	return SUCCESSFUL_RETURN;
}
Beispiel #20
0
	void right(float distance){
		setPosition(position + distance * getU());
	}
Beispiel #21
0
	void pitch(Angle angle){
		const Mat4 rotation = Mat4::rotation(getU().normalize(), angle);
		transformNormals(rotation);
	}
/// Returns the Debye-Waller factor, using an isotropic atomic displacement and
/// the stored unit cell.
double IsotropicAtomBraggScatterer::getDebyeWallerFactor(const V3D &hkl) const {
    V3D dstar = getCell().getB() * hkl;

    return exp(-2.0 * M_PI * M_PI * getU() * dstar.norm2());
}
Beispiel #23
0
 //! Returns the number of nonzero entries in the global graph.
 int getGlobalNumEntries() const {return(getL().getGlobalNumEntries()+getU().getGlobalNumEntries());}
Beispiel #24
0
peanoclaw::records::DataPacked peanoclaw::records::Data::convert() const{
   return DataPacked(
      getU()
   );
}
Beispiel #25
0
void peanoclaw::records::Data::toString (std::ostream& out) const {
   out << "("; 
   out << "u:" << getU();
   out <<  ")";
}
Beispiel #26
0
//---------------------------------------------------------------------------
BezierSurface::BezierSurface(const unsigned rows,
							 const unsigned cols,
							 const unsigned detalization,
							 const bool _gridHidden,
							 const bool _useFilling = true)
	: gridHidden(_gridHidden),
	  useFilling(_useFilling),
	  ptsPerUnit(detalization),
	  lastCanvasSize(TSize(0, 0)),
	  zBuffer(NULL)
{
	frontColor = clRed;
	backColor = clBlack;

	points_container knots = points_container(rows, vector<Vertice *>(cols, 0));
	points_container points = points_container(ptsPerUnit + 1, vector<Vertice *>(ptsPerUnit + 1, 0));

	if(useFilling) {
		surfaceTriangles.reserve(2 * ptsPerUnit * ptsPerUnit);
	}
	else {
		surfaceWire.reserve(2 * ptsPerUnit * ptsPerUnit);
	}

	randomize();
	int x0 = irand(30);
	int y0 = -random(50);
	int z0 = irand(30);
	int lastx, lasty = y0, lastz = z0;

	for (unsigned i = 0; i < rows; ++i)
	{
		lastx = x0;

		for (unsigned j = 0; j < cols; ++j)
		{
			lastx += (j) ? irand(15) + 10 : irand(50);

			int x = lastx;
			int y = lasty + irand(30) + 1;
			int z = lastz + irand(60);

			UnicodeString tag = knotTag(i, j);
			Vertice *point = new Vertice (x, y, z, tag);

			knots[i][j] = point;
		}

		lasty += 10 + random(20);
	}

	grid = new GraphicObject();

	for(poIt i = knots.begin(); i != knots.end(); ++i) {
		for(pIt j = (*i).begin(); j != (*i).end(); ++j) {
			grid->addVertice(*j);
		}
	}

	for (unsigned i = 0; i < rows; ++i)
	{
		for (unsigned j = 0; j < cols - 1; ++j)
		{
			Edge *edge = new Edge(knotTag(i, j), knotTag(i, j + 1));
			edge->setPen(clBlue, 2, psSolid);
			grid->addEdge(edge);
		}
	}

	for (unsigned j = 0; j < cols; ++j)
	{
		for (unsigned i = 0; i < rows - 1; ++i)
		{
			Edge *edge = new Edge(knotTag(i, j), knotTag(i + 1, j));
			edge->setPen(clBlue, 2, psSolid);
			grid->addEdge(edge);
		}
	}

	// Surfacing

	Matrix *U, *W, *N, *M, *B, *UN, *MW;
	N = BezierSurface::getN(rows - 1);
	M = BezierSurface::getN(cols - 1);

	int row, col = 0;

	for(float u = 0; u <= 1; u += 1.0/(float)ptsPerUnit, ++col) {
		U = getU(u, rows - 1);
		UN = new Matrix(*U * *N);

		row = 0;

		for(float w = 0; w <= 1; w += 1.0/(float)ptsPerUnit, ++row) {
			W = getW(w, cols - 1);
			MW = new Matrix(*M * *W);

			B = new Matrix(rows, cols);

			double x;
			double y;
			double z;

			for(unsigned i = 0; i < rows; ++i) {
				for(unsigned j = 0; j < cols; ++j) {
                    B->values[i][j] = knots[i][j]->getX();
                }
			}

			Matrix Q1 = *UN * *B * *MW;
			x = Q1.values[0][0];

			for(unsigned i = 0; i < rows; ++i) {
				for(unsigned j = 0; j < cols; ++j) {
					B->values[i][j] = knots[i][j]->getY();
                }
			}

			Matrix Q2 = *UN * *B * *MW;
			y = Q2.values[0][0];
			for(unsigned i = 0; i < rows; ++i) {
				for(unsigned j = 0; j < cols; ++j) {
					B->values[i][j] = knots[i][j]->getZ();
                }
			}

			Matrix Q3 = *U * *N * *B * *M * *W;
			z = Q3.values[0][0];

			UnicodeString tag = pointTag(row, col);
			Vertice *pt = new Vertice(x, y, z, tag);

			points[row][col] = pt;

			delete W;
			delete B;
		}

		delete U;
		delete UN;
	}

	delete N;
	delete M;

	for(unsigned i = 0; i < ptsPerUnit; ++i) {
		for(unsigned j = 0; j < ptsPerUnit; ++j) {
			Vertice *vert1 = points[i][j];
			Vertice *vert2 = points[i][j + 1];
			Vertice *vert3 = points[i + 1][j];
			Vertice *vert4 = points[i + 1][j + 1];

			if(useFilling) {
				Triangle *triangle1 = new Triangle;

				Vertice *a, *b, *c;
				Vertice *verts[3] = {vert1, vert2, vert3};

				a = verts[0];
				b = verts[1];
				c = verts[2];

				triangle1->av = new Vertice(*a);
				triangle1->bv = new Vertice(*b);
				triangle1->cv = new Vertice(*c);

				surfaceTriangles.push_back(triangle1);

				Triangle *triangle2 = new Triangle;

				Vertice *verts2[3] = {vert2, vert3, vert4};

				a = verts2[1];
				b = verts2[0];
				c = verts2[2];

				triangle2->av = new Vertice(*a);
				triangle2->bv = new Vertice(*b);
				triangle2->cv = new Vertice(*c);

				surfaceTriangles.push_back(triangle2);
			}
        }
	}
}
Beispiel #27
0
// topdir = 1..nd
// sidedir = -nd..nd
// toplinknum,sidelinknum = 0..nin-1
void
QOP_staples_deriv(QOP_info_t *info, int nout, int nin,
		  QDP_ColorMatrix *deriv[], QDP_ColorMatrix *chain[],
		  QDP_ColorMatrix *in[],
		  int nstaples[], int *topdir[], int *sidedir[],
		  int *toplinknum[], int *sidelinknum[], QLA_Real *coef[])
{
#define NC QDP_get_nc(in[0])
  double dtime = QOP_time();
  double nflops = 0;
  int nd = QDP_ndim();
  QDP_ColorMatrix *ftmps[nin][nd], *t1, *t2, *t3, *t4, *tc, *bt2[nd], *bt3[nd], *ctmps[nd];
  int ctn[nd];
  for(int i=0; i<nin; i++)
    for(int j=0; j<nd; j++)
      ftmps[i][j] = NULL;
  for(int i=0; i<nd; i++) bt2[i] = bt3[i] = ctmps[i] = NULL;
  t1 = QDP_create_M();
  t2 = QDP_create_M();
  t3 = QDP_create_M();
  t4 = QDP_create_M();
  tc = QDP_create_M();

  // process in reverse in case calculated staples used as input for others
  for(int io=nout-1; io>=0; io--) {
    for(int i=0; i<nd; i++) {
      if(ctmps[i]) QDP_discard_M(ctmps[i]);
      ctn[i] = 0;
    }
    QDP_M_eq_M(tc, chain[io], QDP_all);
    for(int s=0; s<nstaples[io]; s++) {
      QLA_Real c = coef[io][s];
      int tn = toplinknum[io][s];
      int sdir = sidedir[io][s];
      //QOP_printf0("io: %i  s: %i  sdir: %i  tn: %i  c: %g\n", io, s, sdir, tn, c);
      if(sdir==0) {
	if(c==1) {
	  QDP_M_peq_M(deriv[tn], tc, QDP_all);
	  nflops += PEQM;
	} else {
	  QDP_M_peq_r_times_M(deriv[tn], &c, tc, QDP_all);
	  nflops += 2*PEQM;
	}
      } else if(sdir>0) {
	int nu = sdir-1;
	int mu = topdir[io][s]-1;
	int sn = sidelinknum[io][s];
	//QOP_printf0("  mu: %i  nu: %i  sn: %i\n", mu, nu, sn);
	QDP_ColorMatrix *Umunu = getU(tn, mu, nu);
	QDP_ColorMatrix *Unumu = getU(sn, nu, mu);
	QDP_M_eq_M_times_M(t1, in[sn], Umunu, QDP_all);
	QDP_M_eq_Ma_times_M(t2, tc, t1, QDP_all);
	QDP_ColorMatrix *tb2 = shiftb(t2, mu);
	QDP_M_eq_M_times_M(t1, tc, Unumu, QDP_all);
	QDP_M_eq_Ma_times_M(t3, in[sn], t1, QDP_all);
	QDP_ColorMatrix *tb3 = shiftb(t3, nu);
	if(c==1) {
	  QDP_M_peq_M_times_Ma(deriv[sn], t1, Umunu, QDP_all);
	  QDP_M_peq_M(deriv[sn], tb2, QDP_all);
	  QDP_M_peq_M(deriv[tn], tb3, QDP_all);
	  nflops += 4*EQMTM+PEQMTM+2*PEQM;
	} else {
	  QDP_M_eq_M_times_Ma(t4, t1, Umunu, QDP_all);
	  QDP_M_peq_r_times_M(deriv[sn], &c, t4, QDP_all);
	  QDP_M_peq_r_times_M(deriv[sn], &c, tb2, QDP_all);
	  QDP_M_peq_r_times_M(deriv[tn], &c, tb3, QDP_all);
	  nflops += 5*EQMTM+6*PEQM;
	}
	QDP_discard_M(tb2);
	QDP_discard_M(tb3);
      } else {
	int nu = -sdir-1;
	int mu = topdir[io][s]-1;
	int sn = sidelinknum[io][s];
	QDP_ColorMatrix *Cmunu = getC(nu);
	QDP_ColorMatrix *Unumu = getU(sn, nu, mu);
	QDP_M_eq_M_times_M(t1, in[sn], Cmunu, QDP_all);
	QDP_M_eq_Ma_times_M(t2, in[tn], t1, QDP_all);
	QDP_ColorMatrix *tb2 = shiftb(t2, mu);
	QDP_M_eq_M_times_M(t3, in[tn], Unumu, QDP_all);
	if(c==1) {
	  QDP_M_peq_M_times_Ma(deriv[tn], t1, Unumu, QDP_all);
	  QDP_M_peq_M_times_Ma(deriv[sn], t3, Cmunu, QDP_all);
	  QDP_M_peq_M(deriv[sn], tb2, QDP_all);
	  nflops += 3*EQMTM+2*PEQMTM+PEQM;
	} else {
	  QDP_M_eq_M_times_Ma(t4, t1, Unumu, QDP_all);
	  QDP_M_peq_r_times_M(deriv[tn], &c, t4, QDP_all);
	  QDP_M_eq_M_times_Ma(t4, t3, Cmunu, QDP_all);
	  QDP_M_peq_r_times_M(deriv[sn], &c, t4, QDP_all);
	  QDP_M_peq_r_times_M(deriv[sn], &c, tb2, QDP_all);
	  nflops += 5*EQMTM+6*PEQM;
	}
	QDP_discard_M(tb2);
      }
    }
  }

  for(int i=0; i<nin; i++)
    for(int j=0; j<nd; j++)
      if(ftmps[i][j]!=NULL) QDP_destroy_M(ftmps[i][j]);
  for(int i=0; i<nd; i++) {
    if(bt2[i]!=NULL) QDP_destroy_M(bt2[i]);
    if(bt3[i]!=NULL) QDP_destroy_M(bt3[i]);
    if(ctmps[i]!=NULL) QDP_destroy_M(ctmps[i]);
  }
  QDP_destroy_M(t1);
  QDP_destroy_M(t2);
  QDP_destroy_M(t3);
  QDP_destroy_M(t4);
  QDP_destroy_M(tc);
  info->final_sec = QOP_time() - dtime;
  info->final_flop = nflops*QDP_sites_on_node; 
  info->status = QOP_SUCCESS;
#undef NC
}
Beispiel #28
0
float BlockDerivative::update(float input)
{
	float output = _lowPass.update((input - getU()) / getDt());
	setU(input);
	return output;
}
Beispiel #29
0
// topdir = 1..nd
// sidedir = -nd..nd
// toplinknum,sidelinknum = 0..nin-1
void
QOP_staples(QOP_info_t *info, int nout, int nin,
	    QDP_ColorMatrix *out[], QDP_ColorMatrix *in[],
	    int nstaples[], int *topdir[], int *sidedir[],
	    int *toplinknum[], int *sidelinknum[], QLA_Real *coef[])
{
#define NC QDP_get_nc(in[0])
  double dtime = QOP_time();
  double nflops = 0;
  int nd = QDP_ndim();
  QDP_ColorMatrix *ftmps[nin][nd], *t1, *t2, *bt2[nd];
  for(int i=0; i<nin; i++)
    for(int j=0; j<nd; j++)
      ftmps[i][j] = NULL;
  for(int i=0; i<nd; i++) bt2[i] = NULL;
  t1 = QDP_create_M();
  t2 = QDP_create_M();

  for(int io=0; io<nout; io++) {
    //QOP_printf0("%i: ns: %i\n", io, nstaples[io]);
    for(int s=0; s<nstaples[io]; s++) {
      QLA_Real c = coef[io][s];
      int tn = toplinknum[io][s];
      int sdir = sidedir[io][s];
      //QOP_printf0(" %i:  sdir: %i  c: %g\n", s, sdir, c);
      if(sdir==0) {
	if(c==1) {
	  QDP_M_peq_M(out[io], in[tn], QDP_all);
	  nflops += PEQM;
	} else {
	  QDP_M_peq_r_times_M(out[io], &c, in[tn], QDP_all);
	  nflops += 2*PEQM;
	}
      } else if(sdir>0) {
	int nu = sdir-1;
	int mu = topdir[io][s]-1;
	int sn = sidelinknum[io][s];
	QDP_ColorMatrix *Umunu = getU(tn, mu, nu);
	QDP_ColorMatrix *Unumu = getU(sn, nu, mu);
	QDP_M_eq_M_times_M(t1, in[sn], Umunu, QDP_all);
	if(c==1) {
	  QDP_M_peq_M_times_Ma(out[io], t1, Unumu, QDP_all);
	  nflops += EQMTM+PEQMTM;
	} else {
	  QDP_M_eq_M_times_Ma(t2, t1, Unumu, QDP_all);
	  QDP_M_peq_r_times_M(out[io], &c, t2, QDP_all);
	  nflops += 2*EQMTM+2*PEQM;
	}
      } else {
	int nu = -sdir-1;
	int mu = topdir[io][s]-1;
	int sn = sidelinknum[io][s];
	QDP_ColorMatrix *Unumu = getU(sn, nu, mu);
	QDP_M_eq_M_times_M(t1, in[tn], Unumu, QDP_all);
	QDP_M_eq_Ma_times_M(t2, in[sn], t1, QDP_all);
	QDP_ColorMatrix *tb = shiftb(t2, nu);
	if(c==1) {
	  QDP_M_peq_M(out[io], tb, QDP_all);
	  nflops += 2*EQMTM+PEQM;
	} else {
	  QDP_M_peq_r_times_M(out[io], &c, tb, QDP_all);
	  nflops += 2*EQMTM+2*PEQM;
	}
	QDP_discard_M(tb);
      }
    }
  }

  for(int i=0; i<nin; i++)
    for(int j=0; j<nd; j++)
      if(ftmps[i][j]!=NULL) QDP_destroy_M(ftmps[i][j]);
  for(int i=0; i<nd; i++) if(bt2[i]!=NULL) QDP_destroy_M(bt2[i]);
  QDP_destroy_M(t1);
  QDP_destroy_M(t2);
  info->final_sec = QOP_time() - dtime;
  info->final_flop = nflops*QDP_sites_on_node; 
  info->status = QOP_SUCCESS;
#undef NC
}
Beispiel #30
0
 /**
  * @return the number of users.
  */
 size_t getNumberOfUsers(void){return getU().size1();}