Esempio n. 1
0
double
do_time_teuchos_fad_dot(unsigned int m, unsigned int ndot, unsigned int nloop)
{
  Sacado::Random<double> urand(0.0, 1.0);
  Teuchos::BLAS<int,FadType> blas;

  std::vector<FadType> X(m), Y(m);
  for (unsigned int i=0; i<m; i++) {
    X[i] = FadType(ndot, urand.number());
    Y[i] = FadType(ndot, urand.number());
    for (unsigned int k=0; k<ndot; k++) {
      X[i].fastAccessDx(k) = urand.number();
      Y[i].fastAccessDx(k) = urand.number();
    }
  }
  
  Teuchos::Time timer("Teuchos Fad DOT", false);
  timer.start(true);
  for (unsigned int j=0; j<nloop; j++) {
    FadType z = blas.DOT(m, &X[0], 1, &Y[0], 1);
  }
  timer.stop();

  return timer.totalElapsedTime() / nloop;
}
Esempio n. 2
0
/*
  Computes integrals of monomials over a given reference cell.
*/
double computeIntegral(shards::CellTopology & cellTopology, int cubDegree, int xDeg, int yDeg, int zDeg) {

  DefaultCubatureFactory<double>  cubFactory;                                         // create factory
  Teuchos::RCP<Cubature<double> > myCub = cubFactory.create(cellTopology, cubDegree); // create default cubature

  double val       = 0.0;
  int cubDim       = myCub->getDimension();
  int numCubPoints = myCub->getNumPoints();

  FieldContainer<double> point(cubDim);
  FieldContainer<double> cubPoints(numCubPoints, cubDim);
  FieldContainer<double> cubWeights(numCubPoints);
  FieldContainer<double> functValues(numCubPoints);

  myCub->getCubature(cubPoints, cubWeights);

  for (int i=0; i<numCubPoints; i++) {
    for (int j=0; j<cubDim; j++) {
      point(j) = cubPoints(i,j);
    }
    functValues(i) = computeMonomial(point, xDeg, yDeg, zDeg);
  }

  Teuchos::BLAS<int, double> myblas;
  int inc = 1;
  val = myblas.DOT(numCubPoints, &functValues[0], inc, &cubWeights[0], inc);

  return val;
}
Esempio n. 3
0
void Arnoldi::_Orthogonalize(cSDV& q){
    Teuchos::BLAS<int, complex<double> > blas;
    complex<double> OrthogFactor;

    for( int j = 0; j <= _k; ++j ){
        OrthogFactor = blas.DOT(_length, q.values(), 1, _Q[j], 1);
        _H[_k][j] = OrthogFactor;
        complex<double>* iterQ = _Q[j];
        complex<double>* iterq = q.values();
        for( int i = 0; i < _length; ++i, ++iterQ, ++iterq ){
           *iterq -= OrthogFactor*(*iterQ);
        }
    }
}
Esempio n. 4
0
double
do_time_teuchos_double_dot(unsigned int m, unsigned int nloop)
{
  Sacado::Random<double> urand(0.0, 1.0);
  Teuchos::BLAS<int,double> blas;

  std::vector<double> X(m), Y(m);
  for (unsigned int i=0; i<m; i++) {
    X[i] = urand.number();
    Y[i] = urand.number();
  }
  
  Teuchos::Time timer("Teuchos Double DOT", false);
  timer.start(true);
  double z;
  for (unsigned int j=0; j<nloop; j++) {
    z += blas.DOT(m, &X[0], 1, &Y[0], 1);
  }
  timer.stop();

  return timer.totalElapsedTime() / nloop;
}