void
GenericMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix(const P_V& positionVector1, const P_V& positionVector2, Q_M& imageMatrix) const
{
  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
    *m_env.subDisplayFile() << "Entering GenericMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()"
                            << std::endl;
  }

  unsigned int matrixOrder = m_imageSet.vectorSpace().dimLocal();

  queso_require_equal_to_msg(imageMatrix.numRowsLocal(), matrixOrder, "imageMatrix has invalid number of rows");

  queso_require_equal_to_msg(imageMatrix.numCols(), matrixOrder, "imageMatrix has invalid number of columns");

  queso_require_msg(m_covRoutinePtr, "m_covRoutinePtr = NULL");

  m_covRoutinePtr(positionVector1, positionVector2, m_routineDataPtr, imageMatrix);

  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
    *m_env.subDisplayFile() << "Leaving GenericMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()"
                            << std::endl;
  }

  return;
}
void
ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix(const P_V& domainVector1, const P_V& domainVector2, Q_M& imageMatrix) const
{
  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
    *m_env.subDisplayFile() << "Entering ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()"
                          << std::endl;
  }

  unsigned int matrixOrder = m_imageSet.vectorSpace().dimLocal();

  queso_require_equal_to_msg(imageMatrix.numRowsLocal(), matrixOrder, "imageMatrix has invalid number of rows");

  queso_require_equal_to_msg(imageMatrix.numCols(), matrixOrder, "imageMatrix has invalid number of columns");

  double tmpSq = -(domainVector1 - domainVector2).norm2Sq();

  for (unsigned int i = 0; i < matrixOrder; ++i) {
    for (unsigned int j = 0; j < matrixOrder; ++j) {
      double tmp = tmpSq/( (*m_sigmas)(i,j) * (*m_sigmas)(i,j) );
      imageMatrix(i,j) = (*m_as)(i,j) * std::exp(tmp);
    }
  }

  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
    *m_env.subDisplayFile() << "Leaving ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()"
                          << std::endl;
  }

  return;
}
Example #3
0
void
GslVector::cwSetBeta(const GslVector& alpha, const GslVector& beta)
{
  queso_require_equal_to_msg(this->sizeLocal(), alpha.sizeLocal(), "incompatible alpha size");

  queso_require_equal_to_msg(this->sizeLocal(), beta.sizeLocal(), "incompatible beta size");

  double tmpSample = 0.;
  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
    tmpSample = m_env.rngObject()->betaSample(alpha[i],beta[i]);
    if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
      *m_env.subDisplayFile() << "In GslVector::cwSetBeta()"
                              << ": fullRank "   << m_env.fullRank()
                              << ", i = "        << i
                              << ", alpha[i] = " << alpha[i]
                              << ", beta[i] = "  << beta[i]
                              << ", sample = "   << tmpSample
                              << std::endl;
    }
    if ((alpha[i] == 1. ) &&
        (beta [i] == 0.1)) {
      if (tmpSample == 1.) {
        if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
          *m_env.subDisplayFile() << "Hitting 'sampe = 1' in GslVector::cwSetBeta()"
                                  << ": fullRank "   << m_env.fullRank()
                                  << ", i = "        << i
                                  << ", alpha[i] = " << alpha[i]
                                  << ", beta[i] = "  << beta[i]
                                  << ", sample = "   << tmpSample
                                  << std::endl;
        }
#if 1
        std::cerr << "Hitting 'sample = 1' in GslVector::cwSetBeta()"
                  << ": fullRank "   << m_env.fullRank()
                  << ", i = "        << i
                  << ", alpha[i] = " << alpha[i]
                  << ", beta[i] = "  << beta[i]
                  << ", sample = "   << tmpSample
                  << std::endl;
        do {
          tmpSample = m_env.rngObject()->betaSample(alpha[i],beta[i]);
        } while (tmpSample == 1.);
        std::cerr << "Code was able to get 'sample != 1' in GslVector::cwSetBeta()"
                  << ": fullRank "   << m_env.fullRank()
                  << ", i = "        << i
                  << ", alpha[i] = " << alpha[i]
                  << ", beta[i] = "  << beta[i]
                  << ", sample = "   << tmpSample
                  << std::endl;
      }
#endif
    }
    (*this)[i] = tmpSample;
  }
  return;
}
Example #4
0
// -------------------------------------------------
//updated on 3/18, to use the RngBase+Boost
// Using Gamma Distribution to calculate InverseGamma.
// Note the divisions: 1.0/b and the 1.0/generator; they are crucial
void TeuchosVector::cwSetInverseGamma(const TeuchosVector& alpha, const TeuchosVector& beta)
{
  queso_require_equal_to_msg(this->sizeLocal(), alpha.sizeLocal(), "incompatible alpha size");

  queso_require_equal_to_msg(this->sizeLocal(), beta.sizeLocal(), "incompatible beta size");

  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
    (*this)[i] = 1./m_env.rngObject()->gammaSample(alpha[i],1./beta[i]);
  }
  return;
}
Example #5
0
void
GslVector::mpiBcast(int srcRank, const MpiComm& bcastComm)
{
  // Filter out those nodes that should not participate
  if (bcastComm.MyPID() < 0) return;

  // Check 'srcRank'
  queso_require_msg(!((srcRank < 0) || (srcRank >= bcastComm.NumProc())), "invalud srcRank");

  // Check number of participant nodes
  double localNumNodes = 1.;
  double totalNumNodes = 0.;
  bcastComm.Allreduce((void *) &localNumNodes, (void *) &totalNumNodes, (int) 1, RawValue_MPI_DOUBLE, RawValue_MPI_SUM,
                      "GslVector::mpiBcast()",
                      "failed MPI.Allreduce() for numNodes");
  queso_require_equal_to_msg(((int) totalNumNodes), bcastComm.NumProc(), "inconsistent numNodes");

  // Check that all participant nodes have the same vector size
  double localVectorSize  = this->sizeLocal();
  double sumOfVectorSizes = 0.;
  bcastComm.Allreduce((void *) &localVectorSize, (void *) &sumOfVectorSizes, (int) 1, RawValue_MPI_DOUBLE, RawValue_MPI_SUM,
                      "GslVector::mpiBcast()",
                      "failed MPI.Allreduce() for vectorSize");

  if ( ((unsigned int) sumOfVectorSizes) != ((unsigned int)(totalNumNodes*localVectorSize)) ) {
    std::cerr << "rank "                 << bcastComm.MyPID()
              << ": sumOfVectorSizes = " << sumOfVectorSizes
              << ", totalNumNodes = "    << totalNumNodes
              << ", localVectorSize = "  << localVectorSize
              << std::endl;
  }
  bcastComm.Barrier();
  queso_require_equal_to_msg(((unsigned int) sumOfVectorSizes), ((unsigned int)(totalNumNodes*localVectorSize)), "inconsistent vectorSize");

  // Ok, bcast data
  std::vector<double> dataBuffer((unsigned int) localVectorSize, 0.);
  if (bcastComm.MyPID() == srcRank) {
    for (unsigned int i = 0; i < dataBuffer.size(); ++i) {
      dataBuffer[i] = (*this)[i];
    }
  }

  bcastComm.Bcast((void *) &dataBuffer[0], (int) localVectorSize, RawValue_MPI_DOUBLE, srcRank,
                  "GslVector::mpiBcast()",
                  "failed MPI.Bcast()");

  if (bcastComm.MyPID() != srcRank) {
    for (unsigned int i = 0; i < dataBuffer.size(); ++i) {
      (*this)[i] = dataBuffer[i];
    }
  }

  return;
}
Example #6
0
// -------------------------------------------------
//updated on 3/18, to use the RngBase+Boost
void TeuchosVector::cwSetGamma(const TeuchosVector& aVec, const TeuchosVector& bVec)
{
  queso_require_equal_to_msg(this->sizeLocal(), aVec.sizeLocal(), "incompatible a size");

  queso_require_equal_to_msg(this->sizeLocal(), bVec.sizeLocal(), "incompatible b size");

  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
    (*this)[i] = m_env.rngObject()->gammaSample(aVec[i],bVec[i]);
  }
  return;
}
Example #7
0
void
GslVector::cwSetGamma(const GslVector& a, const GslVector& b)
{
  queso_require_equal_to_msg(this->sizeLocal(), a.sizeLocal(), "incompatible a size");

  queso_require_equal_to_msg(this->sizeLocal(), b.sizeLocal(), "incompatible b size");

  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
    (*this)[i] = m_env.rngObject()->gammaSample(a[i],b[i]);
  }
  return;
}
Example #8
0
// ---------------------------------------------------
TeuchosVector::TeuchosVector(const BaseEnvironment& env, const Map& map, double value)
  :
  Vector(env,map)
{
  m_vec.size(map.NumGlobalElements());
  m_vec = value;

  queso_require_msg(m_vec != NULL, "null vector generated");

  queso_require_equal_to_msg(m_vec.length(), map.NumMyElements(), "incompatible local vec size");

  queso_require_equal_to_msg(m_vec.length(), map.NumGlobalElements(), "incompatible global vec size");

  queso_require_equal_to_msg(m_vec.length(), m_map.NumMyElements(), "incompatible own vec size");
}
Example #9
0
// ---------------------------------------------------
TeuchosVector::TeuchosVector(const TeuchosVector& v)  // mox
  :
  Vector(v.env(),v.map())
 {
   m_vec.size(v.sizeLocal());

  queso_require_msg(m_vec != NULL, "null vector generated");

  queso_require_equal_to_msg(m_vec.length(), v.map().NumMyElements(), "incompatible local vec size");

  queso_require_equal_to_msg(m_vec.length(), v.map().NumGlobalElements(), "incompatible global vec size");
  this->copy(v);

  queso_require_equal_to_msg(m_vec.length(), m_map.NumMyElements(), "incompatible own vec size");
}
Example #10
0
void
GcmZTildeInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::commonConstructor(const GcmZInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>& z)
{
    unsigned int cMatTildeRank   = m_Cmat_tilde.rank(0.,1.e-8 ); // todo: should be an option
    unsigned int cMatTildeRank14 = m_Cmat_tilde.rank(0.,1.e-14);
    if (m_env.subDisplayFile()) {
      *m_env.subDisplayFile() << "In GcmZTildeInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
                              << ": m_Cmat_tilde.numRowsLocal() = "  << m_Cmat_tilde.numRowsLocal()
                              << ", m_Cmat_tilde.numCols() = "       << m_Cmat_tilde.numCols()
                              << ", m_Cmat_tilde.rank(0.,1.e-8) = "  << cMatTildeRank
                              << ", m_Cmat_tilde.rank(0.,1.e-14) = " << cMatTildeRank14
                              << std::endl;
    }
    queso_require_equal_to_msg(cMatTildeRank, z.m_Cmat_rank, "'m_Cmat_tilde' should have full column rank");

    queso_require_less_msg(m_Lmat.numRowsGlobal(), m_Lmat.numCols(), "'m_Lmat' should be a 'horizontal' rectangular matrix");

    //******************************************************************************
    // Tilde situation: form 'm_Lmat_t'
    //******************************************************************************
    m_Lmat_t.fillWithTranspose(0,0,m_Lmat,true,true);
    unsigned int lMatRank   = m_Lmat_t.rank(0.,1.e-8 ); // todo: should be an option
    unsigned int lMatRank14 = m_Lmat_t.rank(0.,1.e-14);
    if (m_env.subDisplayFile()) {
      *m_env.subDisplayFile() << "In GcmZTildeInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::commonConstructor()"
                              << ": m_Lmat.numRowsLocal() = "  << m_Lmat.numRowsLocal()
                              << ", m_Lmat.numCols() = "       << m_Lmat.numCols()
                              << ", m_Lmat.rank(0.,1.e-8) = "  << lMatRank
                              << ", m_Lmat.rank(0.,1.e-14) = " << lMatRank14
                              << std::endl;
    }

    queso_require_equal_to_msg(lMatRank, z.m_Cmat_rank, "'m_Lmat' should have full row rank");

    if (m_env.checkingLevel() >= 1) {
      // Check if C == C_tilde * L
      D_M tmpCmat(m_Cmat_tilde * m_Lmat);
      tmpCmat -= *z.m_Cmat;
      double cDiffNorm = tmpCmat.normFrob();
      if (m_env.subDisplayFile()) {
        *m_env.subDisplayFile() << "In GcmZTildeInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::commonConstructor()"
                                << ": ||tmpC - C||_2 = " << cDiffNorm
                                << std::endl;
      }
    }

  return;
}
Example #11
0
// Constructor with alternative values --------------
EnvironmentOptions::EnvironmentOptions(
    const BaseEnvironment&  env,
    const char*                    prefix,
    const EnvOptionsValues& alternativeOptionsValues)
    :
    m_ov                          (alternativeOptionsValues),
    m_env                         (env),
    m_prefix                      ((std::string)(prefix) + "env_"),
    m_optionsDesc                 (NULL),
    m_option_help                 (m_prefix + "help"                 ),
    m_option_numSubEnvironments   (m_prefix + "numSubEnvironments"   ),
    m_option_subDisplayFileName   (m_prefix + "subDisplayFileName"   ),
    m_option_subDisplayAllowAll   (m_prefix + "subDisplayAllowAll"   ),
    m_option_subDisplayAllowInter0(m_prefix + "subDisplayAllowInter0"),
    m_option_subDisplayAllowedSet (m_prefix + "subDisplayAllowedSet" ),
    m_option_displayVerbosity     (m_prefix + "displayVerbosity"     ),
    m_option_syncVerbosity        (m_prefix + "syncVerbosity"        ),
    m_option_checkingLevel        (m_prefix + "checkingLevel"        ),
    m_option_rngType              (m_prefix + "rngType"              ),
    m_option_seed                 (m_prefix + "seed"                 ),
    m_option_platformName         (m_prefix + "platformName"         ),
    m_option_identifyingString    (m_prefix + "identifyingString"    )
{
    queso_deprecated();
    queso_require_equal_to_msg(m_env.optionsInputFileName(), "", "this constructor is incompatible with the existence of an options input file");

    if (m_env.subDisplayFile() != NULL) {
        *m_env.subDisplayFile() << "In EnvironmentOptions::constructor(2)"
                                << ": after setting values of options with prefix '" << m_prefix
                                << "', state of object is:"
                                << "\n" << *this
                                << std::endl;
    }
}
Example #12
0
void
GslVector::mpiAllQuantile(double probability, const MpiComm& opComm, GslVector& resultVec) const
{
  // Filter out those nodes that should not participate
  if (opComm.MyPID() < 0) return;

  queso_require_msg(!((probability < 0.) || (1. < probability)), "invalid input");

  unsigned int size = this->sizeLocal();
  queso_require_equal_to_msg(size, resultVec.sizeLocal(), "different vector sizes");

  for (unsigned int i = 0; i < size; ++i) {
    double auxDouble = (int) (*this)[i];
    std::vector<double> vecOfDoubles(opComm.NumProc(),0.);
    opComm.Gather((void *) &auxDouble, 1, RawValue_MPI_DOUBLE, (void *) &vecOfDoubles[0], (int) 1, RawValue_MPI_DOUBLE, 0,
                  "GslVector::mpiAllQuantile()",
                  "failed MPI.Gather()");

    std::sort(vecOfDoubles.begin(), vecOfDoubles.end());

    double result = vecOfDoubles[(unsigned int)( probability*((double)(vecOfDoubles.size()-1)) )];

    opComm.Bcast((void *) &result, (int) 1, RawValue_MPI_DOUBLE, 0,
                 "GslVector::mpiAllQuantile()",
                 "failed MPI.Bcast()");

    resultVec[i] = result;
  }

  return;
}
Example #13
0
unsigned int
GslVector::sizeGlobal() const
{
  queso_require_equal_to_msg(m_vec->size, (unsigned int) m_map.NumGlobalElements(), "incompatible vec size");

  return m_vec->size;
}
Example #14
0
double
PoweredJointPdf<V,M>::actualValue(
  const V& domainVector,
  const V* domainDirection,
        V* gradVector,
        M* hessianMatrix,
        V* hessianEffect) const
{
  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
    *m_env.subDisplayFile() << "Entering PoweredJointPdf<V,M>::actualValue()"
                            << ": domainVector = " << domainVector
                            << std::endl;
  }

  queso_require_equal_to_msg(domainVector.sizeLocal(), this->m_domainSet.vectorSpace().dimLocal(), "invalid input");

  double value = m_srcDensity.actualValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect);

  queso_require_msg(!(domainDirection || gradVector || hessianMatrix || hessianEffect), "incomplete code for domainDirection, gradVector, hessianMatrix and hessianEffect calculations");

  double returnValue = pow(value,m_exponent);
  returnValue *= exp(m_logOfNormalizationFactor); // [PDF-08] ???

  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
    *m_env.subDisplayFile() << "Leaving PoweredJointPdf<V,M>::actualValue()"
                            << ": domainVector = " << domainVector
                            << ", returnValue = "  << returnValue
                            << std::endl;
  }

  return returnValue;
}
Example #15
0
unsigned int
GslVector::sizeLocal() const
{
  // mox
  //std::cout << "Entering GslVector::sizeLocal()"
  //          << ": &m_map = "                << &m_map
  //          << std::endl;
  //std::cout << ", m_map.NumMyElements() = " << m_map.NumMyElements()
  //          << std::endl;
  //std::cout << ", m_vec = "                 << m_vec
  //          << std::endl;
  //std::cout << ", m_vec->size = "           << m_vec->size
  //          << std::endl;

  queso_require_equal_to_msg(m_vec->size, (unsigned int) m_map.NumMyElements(), "incompatible vec size");

  //std::cout << "Leaving GslVector::sizeLocal()"
  //          << ": m_vec = " << m_vec
  //          << ", m_vec->size = " << m_vec->size
  //          << ", &m_map = " << &m_map
  //          << ", m_map.NumMyElements() = " << m_map.NumMyElements()
  //          << std::endl;

  return m_vec->size;
}
Example #16
0
double
UniformJointPdf<V,M>::actualValue(
  const V& domainVector,
  const V* domainDirection,
        V* gradVector,
        M* hessianMatrix,
        V* hessianEffect) const
{
  queso_require_equal_to_msg(domainVector.sizeLocal(), this->m_domainSet.vectorSpace().dimLocal(), "invalid input");

  if (gradVector   ) *gradVector     = m_domainSet.vectorSpace().zeroVector();
  if (hessianMatrix) *hessianMatrix *= 0.;
  if (hessianEffect) *hessianEffect  = m_domainSet.vectorSpace().zeroVector();

  if (domainDirection) {}; // just to remove compiler warning

  double volume = m_domainSet.volume();
  if ((queso_isnan(volume)) ||
      (volume == -INFINITY         ) ||
      (volume ==  INFINITY         ) ||
      (volume <= 0.                ) ||
      (m_normalizationStyle != 0   )) {
    volume = 1.;
  }

  return 1./volume; // No need to multiply by exp(m_logOfNormalizationFactor) [PDF-04]
}
Example #17
0
double
BayesianJointPdf<V,M>::actualValue(
  const V& domainVector,
  const V* domainDirection,
        V* gradVector,
        M* hessianMatrix,
        V* hessianEffect) const
{
  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
    *m_env.subDisplayFile() << "Entering BayesianJointPdf<V,M>::actualValue()"
                            << ": domainVector = " << domainVector
                            << std::endl;
  }

  queso_require_equal_to_msg(domainVector.sizeLocal(), this->m_domainSet.vectorSpace().dimLocal(), "invalid input");

  V* gradVLike = NULL;
  if (gradVector) gradVLike = &m_tmpVector1;

  M* hessianMLike = NULL;
  if (hessianMatrix) hessianMLike = m_tmpMatrix;

  V* hessianELike = NULL;
  if (hessianEffect) hessianELike = &m_tmpVector2;

  double value1 = m_priorDensity.actualValue (domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect);
  double value2 = 1.;
  if (m_likelihoodExponent != 0.) {
    value2 = m_likelihoodFunction.actualValue(domainVector,domainDirection,gradVLike ,hessianMLike ,hessianELike );
  }

  queso_require_msg(!(gradVector || hessianMatrix || hessianEffect), "incomplete code for gradVector, hessianMatrix and hessianEffect calculations");

  double returnValue = value1;
  if (m_likelihoodExponent == 0.) {
    // Do nothing
  }
  else if (m_likelihoodExponent == 1.) {
    returnValue *= value2;
  }
  else {
    returnValue *= pow(value2,m_likelihoodExponent);
  }
  returnValue *= exp(m_logOfNormalizationFactor); // [PDF-02] ???

  m_lastComputedLogPrior      = log(value1);
  m_lastComputedLogLikelihood = m_likelihoodExponent*log(value2);

  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
    *m_env.subDisplayFile() << "Leaving BayesianJointPdf<V,M>::actualValue()"
                            << ": domainVector = " << domainVector
                            << ", returnValue = "  << returnValue
                            << std::endl;
  }

  return returnValue;
}
Example #18
0
// ---------------------------------------------------
TeuchosVector::TeuchosVector(const TeuchosVector& v, double d1, double d2)
  :
  Vector(v.env(),v.map())
{
  m_vec.size(v.sizeLocal());

  queso_require_msg(m_vec != NULL, "null vector generated");

  queso_require_equal_to_msg(m_vec.length(), v.map().NumMyElements(), "incompatible local vec size");

  queso_require_equal_to_msg(m_vec.length(), v.map().NumGlobalElements(), "incompatible global vec size");

  for ( int i = 0; i < m_vec.length(); ++i) {
    double alpha = (double) i / ((double) m_vec.length() - 1.);
    (*this)[i] = (1.-alpha)*d1 + alpha*d2;
  }

  queso_require_equal_to_msg(m_vec.length(), m_map.NumMyElements(), "incompatible own vec size");
}
Example #19
0
// ---------------------------------------------------
TeuchosVector::TeuchosVector(const BaseEnvironment& env, double d1, double d2, const Map& map)
  :
  Vector(env,map)
  {
  m_vec.size(map.NumGlobalElements());

  queso_require_msg(m_vec != NULL, "null vector generated");

  queso_require_equal_to_msg(m_vec.length(), map.NumMyElements(), "incompatible local vec size");

  queso_require_equal_to_msg(m_vec.length(), map.NumGlobalElements(), "incompatible global vec size");

  for (int i = 0; i < m_vec.length(); ++i) {
    double alpha = (double) i / ((double) m_vec.length() - 1.);
    (*this)[i] = (1.-alpha)*d1 + alpha*d2;
  }

  queso_require_equal_to_msg(m_vec.length(), m_map.NumMyElements(), "incompatible own vec size");
}
Example #20
0
//-------------------------------------------------
TeuchosVector& TeuchosVector::operator*=(const TeuchosVector& rhs)
{
  unsigned int size1 = this->sizeLocal();
  unsigned int size2 = rhs.sizeLocal();
  queso_require_equal_to_msg(size1, size2, "the vectors do NOT have the same size.\n");
  if (size1==size2){
    for (unsigned int i = 0; i < size1; ++i) {
      (*this)[i] *= rhs[i];
    }
 }
 return *this;
}
Example #21
0
// -------------------------------------------------
void
TeuchosVector::copy_from_std_vector(const std::vector<double> vec)
{
  unsigned int size1 = vec.size(), size2= this->sizeLocal();

  queso_require_equal_to_msg(size1, size2, "vectors have different sizes");

  for (unsigned int i = 0; i < size1; ++i)
      m_vec[i] = vec[i];

  return;
}
Example #22
0
GslVector&
GslVector::operator/=(const GslVector& rhs)
{
  unsigned int size1 = this->sizeLocal();
  unsigned int size2 = rhs.sizeLocal();
  queso_require_equal_to_msg(size1, size2, "different sizes of this and rhs");

  for (unsigned int i = 0; i < size1; ++i) {
    (*this)[i] /= rhs[i];
  }

  return *this;
}
Example #23
0
// -------------------------------------------------
//updated on 3/18, to use the RngBase+Boost
void TeuchosVector::cwSetBeta(const TeuchosVector& alpha, const TeuchosVector& beta)
{
  queso_require_equal_to_msg(this->sizeLocal(), alpha.sizeLocal(), "incompatible alpha size");

  queso_require_equal_to_msg(this->sizeLocal(), beta.sizeLocal(), "incompatible beta size");

  for (unsigned int i = 0; i < this->sizeLocal(); ++i)
  {
    (*this)[i] = m_env.rngObject()->betaSample(alpha[i],beta[i]);

    if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99))
    {
      *m_env.subDisplayFile() << "In TeuchosVector::cwSetBeta()"
                              << ": fullRank "   << m_env.fullRank()
                              << ", i = "        << i
                              << ", alpha[i] = " << alpha[i]
                              << ", beta[i] = "  << beta[i]
                              << ", sample = "   << (*this)[i]
                              << std::endl;
  	}
  }
  return;
};
ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::ExponentialMatrixCovarianceFunction(
  const char*                      prefix,
  const VectorSet<P_V,P_M>& basicDomainSet,
  const VectorSet<Q_V,Q_M>& imageSet,
  const Q_M&                       sigmas,
  const Q_M&                       as)
  :
  BaseMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>(prefix,basicDomainSet,imageSet),
  m_sigmas(NULL),
  m_as    (NULL)
{
  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
    *m_env.subDisplayFile() << "Entering ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::constructor()"
                            << ": prefix = " << m_prefix
                            << std::endl;
  }

  m_sigmas = new Q_M(sigmas);
  m_as     = new Q_M(as);

  unsigned int matrixOrder = m_imageSet.vectorSpace().dimLocal();

  queso_require_equal_to_msg(m_sigmas->numRowsLocal(), matrixOrder, "m_sigmas has invalid number of rows");

  queso_require_equal_to_msg(m_sigmas->numCols(), matrixOrder, "m_sigmas has invalid number of columns");

  queso_require_equal_to_msg(m_as->numRowsLocal(), matrixOrder, "m_as has invalid number of rows");

  queso_require_equal_to_msg(m_as->numCols(), matrixOrder, "m_as has invalid number of columns");

  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
    *m_env.subDisplayFile() << "Leaving ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::constructor()"
                            << ": prefix = " << m_prefix
                            << std::endl;
  }
}
Example #25
0
//-------------------------------------------------
TeuchosVector& TeuchosVector::operator=(const TeuchosVector& rhs)
{
  unsigned int size1 = m_vec.length();
  unsigned int size2 = rhs.sizeLocal();

  queso_require_equal_to_msg(size1, size2, "the vectors do NOT have the same size.\n");

  if (size1==size2){
    for (unsigned int i=0;i<size1;i++){
    m_vec[i]=rhs[i];
    }
  }

  return *this;
}
Example #26
0
// Comparison methods -----------------------------
//-------------------------------------------------
bool
TeuchosVector::atLeastOneComponentSmallerThan(const TeuchosVector& rhs) const
{
  queso_require_equal_to_msg(this->sizeLocal(), rhs.sizeLocal(), "vectors have different sizes");

  bool result = false;
  unsigned int i = 0;
  unsigned int size = this->sizeLocal();
  while ((i < size) && (result == false)) {
    result = ( (*this)[i] < rhs[i] );
    i++;
  };

  return result;
}
Example #27
0
//-------------------------------------------------
bool
TeuchosVector::atLeastOneComponentBiggerOrEqualThan(const TeuchosVector& rhs) const
{
  queso_require_equal_to_msg(this->sizeLocal(), rhs.sizeLocal(), "vectors have different sizes");

  bool result = false;
  unsigned int i = 0;
  unsigned int size = this->sizeLocal();
  while ((i < size) && (result == false)) {
    result = ( (*this)[i] >= rhs[i] ); // prudencio 2012-02-06
    i++;
  };

  return result;
}
Example #28
0
//*****************************************************
// Generic 1D quadrature class
//*****************************************************
Generic1DQuadrature::Generic1DQuadrature(
  double minDomainValue,
  double maxDomainValue,
  const std::vector<double>& positions,
  const std::vector<double>& weights)
  :
  Base1DQuadrature(minDomainValue,maxDomainValue,positions.size()-1)
{
  m_positions = positions;
  m_weights   = weights;

  queso_require_not_equal_to_msg(m_positions.size(), 0, "invalid positions");

  queso_require_equal_to_msg(m_positions.size(), m_weights.size(), "inconsistent positions and weight");
}
Example #29
0
void
GslVector::cwSetConcatenated(const GslVector& v1, const GslVector& v2)
{
  queso_require_equal_to_msg(this->sizeLocal(), v1.sizeLocal() + v2.sizeLocal(), "incompatible vector sizes");

  for (unsigned int i = 0; i < v1.sizeLocal(); ++i) {
    (*this)[i] = v1[i];
  }

  for (unsigned int i = 0; i < v2.sizeLocal(); ++i) {
    (*this)[v1.sizeLocal()+i] = v2[i];
  }

  return;
}
Example #30
0
void
GslVector::cwSetConcatenated(const std::vector<const GslVector* >& vecs)
{
  unsigned int cummulativeSize = 0;
  for (unsigned int i = 0; i < vecs.size(); ++i) {
    GslVector tmpVec(*(vecs[i]));
    for (unsigned int j = 0; j < vecs[i]->sizeLocal(); ++j) {
      (*this)[cummulativeSize+j] = tmpVec[j];
    }
    cummulativeSize += vecs[i]->sizeLocal();
  }

  queso_require_equal_to_msg(this->sizeLocal(), cummulativeSize, "incompatible vector sizes");
  return;
}