25 #include <queso/VectorSpace.h> 
   26 #include <queso/GslVector.h> 
   27 #include <queso/GslMatrix.h> 
   28 #include <queso/TeuchosVector.h> 
   29 #include <queso/TeuchosMatrix.h> 
   30 #include <queso/DistArray.h> 
   31 #include <queso/Map.h> 
   37 template <
class V, 
class M>
 
   39     unsigned int dimGlobalValue,
 
   40     const std::vector<std::string>* componentsNamesVec)
 
   41   : 
VectorSet<V,M> (env,((std::string)(prefix) + 
"space_").c_str(),INFINITY),
 
   42     m_dimGlobal(dimGlobalValue),
 
   44     m_dimLocal(m_map->NumMyElements()),
 
   45     m_componentsNamesArray(NULL),
 
   46     m_componentsNamesVec(NULL),
 
   47     m_emptyComponentName(
""),
 
   48     m_zeroVector(new V(m_env,*m_map))
 
   53                             << 
"\n  m_zeroVector->sizeGlobal() = " << 
m_zeroVector->sizeGlobal()
 
   55                             << 
"\n  m_zeroVector->sizeLocal()  = " << 
m_zeroVector->sizeLocal()
 
   58                             << 
"\n  componentsNamesVec         = " << componentsNamesVec
 
   63     std::cerr << 
"In VectorSpace<V,M>::constructor(1)" 
   65               << 
": m_zeroVector->sizeGlobal() = " << 
m_zeroVector->sizeGlobal()
 
   72     std::cerr << 
"In VectorSpace<V,M>::constructor(1)" 
   74               << 
": m_zeroVector->sizeLocal() = " << 
m_zeroVector->sizeLocal()
 
   80   if (componentsNamesVec != NULL) {
 
   85     for (
unsigned int i = 0; i < 
m_dimLocal; ++i) {
 
   86       (*m_componentsNamesArray)(i,0) = (*componentsNamesVec)[myFirstId+i];
 
  101 template <
class V, 
class M>
 
  103   : 
VectorSet<V,M>(aux.env(),((std::string)(aux.m_prefix)).c_str(),INFINITY),
 
  104     m_dimGlobal(aux.m_dimGlobal),
 
  106     m_dimLocal(m_map->NumMyElements()),
 
  107     m_componentsNamesArray(NULL),
 
  108     m_componentsNamesVec(NULL),
 
  109     m_emptyComponentName(
""),
 
  110     m_zeroVector(new V(m_env,*m_map))
 
  130 template <
class V, 
class M>
 
  133   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
 
  134     *m_env.subDisplayFile() << 
"Entering VectorSpace<V,M>::destructor()" 
  138   if (m_zeroVector           != NULL) 
delete m_zeroVector;
 
  139   if (m_componentsNamesVec   != NULL) 
delete m_componentsNamesVec;
 
  140   if (m_componentsNamesArray != NULL) 
delete m_componentsNamesArray;
 
  141   if (m_map                  != NULL) 
delete m_map;
 
  143   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
 
  144     *m_env.subDisplayFile() << 
"Leaving VectorSpace<V,M>::destructor()" 
  150 template <
class V, 
class M>
 
  156 template <
class V, 
class M>
 
  163 template <
class V, 
class M>
 
  166   return m_map->Comm().NumProc();
 
  169 template <
class V, 
class M>
 
  175 template <
class V, 
class M>
 
  181 template <
class V, 
class M>
 
  184   return m_map->MinMyGID();
 
  188 template<
class V, 
class M>
 
  192   return *m_zeroVector;
 
  195 template <
class V, 
class M>
 
  198   if (v.sizeGlobal() != m_dimGlobal) 
return NULL;
 
  199   if (v.sizeLocal () != m_dimLocal ) 
return NULL;
 
  204 template <
class V, 
class M>
 
  207   if (v.sizeGlobal() != m_dimGlobal) 
return NULL;
 
  208   if (v.sizeLocal () != m_dimLocal ) 
return NULL;
 
  213 template <
class V, 
class M>
 
  216   V tmpVec(*m_zeroVector);
 
  217   for (
unsigned int i = 0; i < m_dimLocal; ++i) {
 
  218     double variance = INFINITY;
 
  219     if (varVec) variance = (*varVec)[i];
 
  220     if (m_env.subDisplayFile()) {
 
  221       *m_env.subDisplayFile() << 
"In VectorSpace<V,M>::newProposalMatrix()" 
  223                               << 
", variance = " << variance
 
  226     if ((variance == INFINITY) ||
 
  227         (variance == NAN     )) {
 
  229         tmpVec[i] = std::pow( fabs((*auxVec)[i])*0.05,2. );
 
  230         if ((tmpVec[i] == 0.      ) ||
 
  231             (tmpVec[i] == INFINITY) ||
 
  232             (tmpVec[i] == NAN     )) {
 
  240     else if (variance == 0.) {
 
  244       tmpVec[i] = variance;
 
  248   return newDiagMatrix(tmpVec);
 
  251 template <
class V, 
class M>
 
  257 template <
class V, 
class M>
 
  263 template <
class V, 
class M>
 
  268   for (
unsigned int i = 0; i < m_dimLocal; ++i) {
 
  273 template <
class V, 
class M>
 
  280   for (
unsigned int i = 0; i < m_dimLocal; ++i) {
 
  285 template <
class V, 
class M>
 
  288   return m_componentsNamesArray;
 
  291 template <
class V, 
class M>
 
  293     unsigned int localComponentId)
 const 
  295   if (m_componentsNamesArray == NULL) 
return m_emptyComponentName;
 
  300   return (*m_componentsNamesArray)(localComponentId,0);
 
  303 template<
class V, 
class M>
 
  305     bool printHorizontally)
 const 
  307   if (printHorizontally) {
 
  308     for (
unsigned int i = 0; i < this->dimLocal(); ++i) {
 
  309       os << 
"'" << this->localComponentName(i) << 
"'" 
  314     for (
unsigned int i = 0; i < this->dimLocal(); ++i) {
 
  315       os << 
"'" << this->localComponentName(i) << 
"'" 
  323 template <
class V, 
class M>
 
  326   os << 
"In VectorSpace<V,M>::print()" 
  327      << 
": nothing to be printed" << std::endl;
 
  334 #ifdef QUESO_HAS_TRILINOS 
unsigned int m_dimGlobal
Global dimension. 
 
const Map & map() const 
Map. 
 
int GlobalLength() const 
Returns the global length of the array. 
 
std::ofstream * subDisplayFile() const 
Access function for m_subDisplayFile (displays file on stream). 
 
void print(std::ostream &os) const 
Prints only a message. 
 
A class representing a vector space. 
 
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
 
~VectorSpace()
Destructor. 
 
int NumGlobalElements() const 
Returns the total number of elements across all processors. 
 
#define queso_require_equal_to_msg(expr1, expr2, msg)
 
void printComponentsNames(std::ostream &os, bool printHorizontally) const 
Prints the local component names. 
 
unsigned int globalIdOfFirstComponent() const 
 
A class for partitioning vectors and matrices. 
 
const V & zeroVector() const 
Returns a vector filled with zeros. 
 
int MyLength() const 
Returns the length of the locally owned array. 
 
V * m_zeroVector
A vector of all elements equal to zero. 
 
#define queso_assert_equal_to(expr1, expr2)
 
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.). 
 
const std::string & localComponentName(unsigned int localComponentId) const 
Returns the local component names. 
 
A templated class for handling sets. 
 
void moments(M &vec) const 
The (INFINITY/nonexistent) matrix of second moments of the space. 
 
VectorSpace()
Default constructor. 
 
DistArray< std::string > * m_componentsNamesVec
Vector of strings of the type DistArray to store the names of the components. 
 
const BaseEnvironment & env() const 
Environment. 
 
#define queso_require_less_equal_msg(expr1, expr2, msg)
 
unsigned int displayVerbosity() const 
 
bool contains(const V &vec) const 
Whether  vector contains vector vec. 
 
unsigned int dimGlobal() const 
 
#define queso_require_msg(asserted, msg)
 
V * newVector() const 
Creates an empty vector of size given by Map& map. See template specialization. 
 
M * newDiagMatrix(const V &v) const 
Creates a diagonal matrix with the elements and size of vector v. 
 
void centroid(V &vec) const 
The (INFINITY/nonexistent) centroid of the space. 
 
const DistArray< std::string > * componentsNamesArray() const 
Access to private attribute m_componentsNamesArray, which is an instance of DistArray. 
 
const BaseEnvironment & m_env
 
unsigned int numOfProcsForStorage() const 
Returns total number of processes. 
 
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components. 
 
M * newProposalMatrix(const V *varVec, const V *auxVec) const 
Creates a diagonal matrix conditionally to values from vector varVec, guaranteeing that its values ar...
 
const VectorSpace< V, M > & vectorSpace() const 
Accessor method to this. Vector space to which this vector set belongs to. 
 
unsigned int dimLocal() const