queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::VectorSpace< V, M > Class Template Reference

A class representing a vector space. More...

#include <VectorSet.h>

Inheritance diagram for QUESO::VectorSpace< V, M >:
QUESO::VectorSet< V, M >

Public Member Functions

template<>
GslVectornewVector () const
 
template<>
GslVectornewVector (double value) const
 
template<>
GslMatrixnewMatrix () const
 
template<>
GslMatrixnewDiagMatrix (double diagValue) const
 
template<>
TeuchosVectornewVector () const
 
template<>
TeuchosVectornewVector (double value) const
 
template<>
TeuchosMatrixnewMatrix () const
 
template<>
TeuchosMatrixnewDiagMatrix (double diagValue) const
 
Constructor/Destructor methods
 VectorSpace (const BaseEnvironment &env, const char *prefix, unsigned int dimGlobalValue, const std::vector< std::string > *componentsNamesVec)
 Shaped constructor. More...
 
 ~VectorSpace ()
 Destructor. More...
 
Attribute methods
const BaseEnvironmentenv () const
 Environment. More...
 
const Mapmap () const
 Map. More...
 
unsigned int numOfProcsForStorage () const
 Returns total number of processes. More...
 
unsigned int dimLocal () const
 
unsigned int dimGlobal () const
 
unsigned int globalIdOfFirstComponent () const
 
Mathematical methods
const V & zeroVector () const
 Returns a vector filled with zeros. More...
 
V * newVector () const
 Creates an empty vector of size given by Map& map. See template specialization. More...
 
V * newVector (double value) const
 Creates a vector of size given by Map& map and all values give by value. See template specialization. More...
 
V * newVector (const V &v) const
 Creates vector as a copy of another. More...
 
M * newMatrix () const
 Creates an empty matrix of size given by Map& map. See template specialization. More...
 
M * newDiagMatrix (const V &v) const
 Creates a diagonal matrix with the elements and size of vector v. More...
 
M * newDiagMatrix (double diagValue) const
 Creates a diagonal matrix with the elements diagValue and size given by Map& map. See template specialization. More...
 
M * newProposalMatrix (const V *varVec, const V *auxVec) const
 Creates a diagonal matrix conditionally to values from vector varVec, guaranteeing that its values are neither 0, NAN nor INFINITY. More...
 
const VectorSpace< V, M > & vectorSpace () const
 Accessor method to this. Vector space to which this vector set belongs to. More...
 
bool contains (const V &vec) const
 Whether vector contains vector vec. More...
 
void centroid (V &vec) const
 The (INFINITY/nonexistent) centroid of the space. More...
 
void moments (M &vec) const
 The (INFINITY/nonexistent) matrix of second moments of the space. More...
 
const DistArray< std::string > * componentsNamesArray () const
 Access to private attribute m_componentsNamesArray, which is an instance of DistArray. More...
 
const std::vector< std::string > * componentsNamesVec () const
 Access to private attribute m_componentsNamesVec. More...
 
const std::string & localComponentName (unsigned int localComponentId) const
 Returns the local component names. More...
 
I/O methods
void printComponentsNames (std::ostream &os, bool printHorizontally) const
 Prints the local component names. More...
 
void print (std::ostream &os) const
 Prints only a message. More...
 
- Public Member Functions inherited from QUESO::VectorSet< V, M >
 VectorSet (const BaseEnvironment &env, const char *prefix, double volume)
 Shaped constructor. More...
 
virtual ~VectorSet ()
 Virtual destructor. More...
 
const BaseEnvironmentenv () const
 Environment. Access to private attribute m_env. More...
 
const std::string & prefix () const
 Access to private attribute m_prefix. More...
 
double volume () const
 Set volume; access to private attribute m_volume. More...
 

Protected Member Functions

MapnewMap ()
 Creates a new map. See template specialization. More...
 
template<>
MapnewMap ()
 
template<>
MapnewMap ()
 

Protected Attributes

unsigned int m_dimGlobal
 Global dimension. More...
 
const Mapm_map
 Map. More...
 
unsigned int m_dimLocal
 Local dimension (number of elements owned by the calling processor.). More...
 
DistArray< std::string > * m_componentsNamesArray
 Array of strings of the type DistArray to store the names of the components. More...
 
DistArray< std::string > * m_componentsNamesVec
 Vector of strings of the type DistArray to store the names of the components. More...
 
std::string m_emptyComponentName
 Empty string for the components names. More...
 
V * m_zeroVector
 A vector of all elements equal to zero. More...
 
- Protected Attributes inherited from QUESO::VectorSet< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
double m_volume
 

Private Member Functions

 VectorSpace ()
 Default constructor. More...
 
 VectorSpace (const VectorSpace< V, M > &aux)
 Copy constructor. More...
 

Detailed Description

template<class V, class M>
class QUESO::VectorSpace< V, M >

A class representing a vector space.

Template classes V and M are to represent a vector class and a matrix class respectively. Currently (as of version 0.46.0) QUESO has matrix and vector classes implemented using either GSL or Trilinos-Teuchos libraries.

Definition at line 49 of file VectorSet.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::VectorSpace< V, M >::VectorSpace ( const BaseEnvironment env,
const char *  prefix,
unsigned int  dimGlobalValue,
const std::vector< std::string > *  componentsNamesVec 
)

Shaped constructor.

Construct a vector space with QUESO environment env and of dimension dimGlobalValue.

Definition at line 38 of file VectorSpace.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::VectorSpace< V, M >::globalIdOfFirstComponent(), QUESO::DistArray< T >::GlobalLength(), QUESO::VectorSpace< V, M >::m_componentsNamesArray, QUESO::VectorSpace< V, M >::m_dimGlobal, QUESO::VectorSpace< V, M >::m_dimLocal, QUESO::VectorSet< V, M >::m_env, QUESO::VectorSpace< V, M >::m_map, QUESO::VectorSet< V, M >::m_prefix, QUESO::VectorSpace< V, M >::m_zeroVector, QUESO::DistArray< T >::MyLength(), QUESO::Map::NumGlobalElements(), QUESO::queso_require_equal_to_msg, and QUESO::BaseEnvironment::subDisplayFile().

41  : VectorSet<V,M> (env,((std::string)(prefix) + "space_").c_str(),INFINITY),
42  m_dimGlobal(dimGlobalValue),
43  m_map(newMap()),
48  m_zeroVector(new V(m_env,*m_map))
49 {
50  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
51  *m_env.subDisplayFile() << "Entering VectorSpace<V,M>::constructor(1)"
52  << ", with m_prefix = " << m_prefix
53  << "\n m_zeroVector->sizeGlobal() = " << m_zeroVector->sizeGlobal()
54  << "\n m_dimGlobal = " << m_dimGlobal
55  << "\n m_zeroVector->sizeLocal() = " << m_zeroVector->sizeLocal()
56  << "\n m_dimLocal = " << m_dimLocal
57  << "\n m_map->NumGlobalElements() = " << m_map->NumGlobalElements()
58  << "\n componentsNamesVec = " << componentsNamesVec
59  << std::endl;
60  }
61 
62  if (m_zeroVector->sizeGlobal() != m_dimGlobal) {
63  std::cerr << "In VectorSpace<V,M>::constructor(1)"
64  << ", with m_prefix = " << m_prefix
65  << ": m_zeroVector->sizeGlobal() = " << m_zeroVector->sizeGlobal()
66  << ", m_dimGlobal = " << m_dimGlobal
67  << std::endl;
68  }
69  queso_require_equal_to_msg(m_zeroVector->sizeGlobal(), m_dimGlobal, "global size of 'm_zeroVector' is not equal to m_dimGlobal");
70 
71  if (m_zeroVector->sizeLocal() != m_dimLocal) {
72  std::cerr << "In VectorSpace<V,M>::constructor(1)"
73  << ", with m_prefix = " << m_prefix
74  << ": m_zeroVector->sizeLocal() = " << m_zeroVector->sizeLocal()
75  << ", m_dimLocal = " << m_dimLocal
76  << std::endl;
77  }
78  queso_require_equal_to_msg(m_zeroVector->sizeLocal(), m_dimLocal, "local size of 'm_zeroVector' is not equal to m_dimLocal");
79 
80  if (componentsNamesVec != NULL) {
81  queso_require_equal_to_msg(componentsNamesVec->size(), (size_t) m_dimGlobal, "global size of 'componentsNames' is not equal to m_dimGlobal");
82 
83  m_componentsNamesArray = new DistArray<std::string>(*m_map,1);
84  unsigned int myFirstId = this->globalIdOfFirstComponent();
85  for (unsigned int i = 0; i < m_dimLocal; ++i) {
86  (*m_componentsNamesArray)(i,0) = (*componentsNamesVec)[myFirstId+i];
87  }
88 
89  queso_require_equal_to_msg(m_componentsNamesArray->GlobalLength(), (int) m_dimGlobal, "global size of 'm_componentsNamesArray' is not equal to m_dimGlobal");
90  queso_require_equal_to_msg(m_componentsNamesArray->MyLength(), (int) m_dimLocal, "local size of 'm_componentsNamesArray' is not equal to m_dimLocal");
91  }
92 
93  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
94  *m_env.subDisplayFile() << "Leaving VectorSpace<V,M>::constructor(1)"
95  << ", with m_prefix = " << m_prefix
96  << std::endl;
97  }
98 }
std::string m_emptyComponentName
Empty string for the components names.
Definition: VectorSpace.h:165
const Map * m_map
Map.
Definition: VectorSpace.h:153
const std::string & prefix() const
Access to private attribute m_prefix.
Definition: VectorSet.C:84
Map * newMap()
Creates a new map. See template specialization.
const BaseEnvironment & env() const
Environment.
Definition: VectorSpace.C:136
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:156
const BaseEnvironment & m_env
Definition: VectorSet.h:104
DistArray< std::string > * m_componentsNamesVec
Vector of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:162
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:159
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
unsigned int globalIdOfFirstComponent() const
Definition: VectorSpace.C:167
int GlobalLength() const
Returns the global length of the array.
Definition: DistArray.C:107
int MyLength() const
Returns the length of the locally owned array.
Definition: DistArray.C:118
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
std::string m_prefix
Definition: VectorSet.h:105
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:168
unsigned int displayVerbosity() const
Definition: Environment.C:450
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:150
const std::vector< std::string > * componentsNamesVec() const
Access to private attribute m_componentsNamesVec.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
QUESO::VectorSpace< V, M >::~VectorSpace ( )

Destructor.

Definition at line 116 of file VectorSpace.C.

117 {
118  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
119  *m_env.subDisplayFile() << "Entering VectorSpace<V,M>::destructor()"
120  << std::endl;
121  }
122 
123  if (m_zeroVector != NULL) delete m_zeroVector;
124  if (m_componentsNamesVec != NULL) delete m_componentsNamesVec;
126  if (m_map != NULL) delete m_map;
127 
128  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
129  *m_env.subDisplayFile() << "Leaving VectorSpace<V,M>::destructor()"
130  << std::endl;
131  }
132 }
const Map * m_map
Map.
Definition: VectorSpace.h:153
const BaseEnvironment & m_env
Definition: VectorSet.h:104
DistArray< std::string > * m_componentsNamesVec
Vector of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:162
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:159
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:168
unsigned int displayVerbosity() const
Definition: Environment.C:450
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V, class M>
QUESO::VectorSpace< V, M >::VectorSpace ( )
private

Default constructor.

template<class V, class M>
QUESO::VectorSpace< V, M >::VectorSpace ( const VectorSpace< V, M > &  aux)
private

Copy constructor.

Definition at line 102 of file VectorSpace.C.

103  : VectorSet<V,M>(aux.env(),((std::string)(aux.m_prefix)).c_str(),INFINITY),
104  m_dimGlobal(aux.m_dimGlobal),
105  m_map(newMap()),
108  m_componentsNamesVec(NULL),
110  m_zeroVector(new V(m_env,*m_map))
111 {
112 }
std::string m_emptyComponentName
Empty string for the components names.
Definition: VectorSpace.h:165
const Map * m_map
Map.
Definition: VectorSpace.h:153
Map * newMap()
Creates a new map. See template specialization.
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:156
const BaseEnvironment & m_env
Definition: VectorSet.h:104
DistArray< std::string > * m_componentsNamesVec
Vector of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:162
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:159
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:168
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:150

Member Function Documentation

template<class V, class M >
void QUESO::VectorSpace< V, M >::centroid ( V &  vec) const
virtual

The (INFINITY/nonexistent) centroid of the space.

Implements QUESO::VectorSet< V, M >.

Definition at line 249 of file VectorSpace.C.

250 {
251  queso_assert_equal_to (m_dimLocal, vec.sizeLocal());
252 
253  for (unsigned int i = 0; i < m_dimLocal; ++i) {
254  vec[i] = INFINITY;
255  }
256 }
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:156
template<class V , class M >
const DistArray< std::string > * QUESO::VectorSpace< V, M >::componentsNamesArray ( ) const

Access to private attribute m_componentsNamesArray, which is an instance of DistArray.

Definition at line 271 of file VectorSpace.C.

272 {
273  return m_componentsNamesArray;
274 }
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:159
template<class V, class M>
const std::vector<std::string>* QUESO::VectorSpace< V, M >::componentsNamesVec ( ) const

Access to private attribute m_componentsNamesVec.

template<class V, class M >
bool QUESO::VectorSpace< V, M >::contains ( const V &  vec) const
virtual

Whether vector contains vector vec.

Implements QUESO::VectorSet< V, M >.

Definition at line 243 of file VectorSpace.C.

244 {
245  return true;
246 }
template<class V , class M >
unsigned int QUESO::VectorSpace< V, M >::dimGlobal ( ) const

Definition at line 161 of file VectorSpace.C.

Referenced by QUESO::ComputeCovCorrMatricesBetweenVectorSequences(), QUESO::GPMSAFactory< V, M >::GPMSAFactory(), and QUESO::InstantiateIntersection().

162 {
163  return m_dimGlobal;
164 }
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:150
template<class V , class M >
const BaseEnvironment & QUESO::VectorSpace< V, M >::env ( ) const

Environment.

Definition at line 136 of file VectorSpace.C.

Referenced by QUESO::InstantiateIntersection().

137 {
138  return m_env;
139 }
const BaseEnvironment & m_env
Definition: VectorSet.h:104
template<class V , class M >
unsigned int QUESO::VectorSpace< V, M >::globalIdOfFirstComponent ( ) const

Definition at line 167 of file VectorSpace.C.

Referenced by QUESO::VectorSpace< V, M >::VectorSpace().

168 {
169  return m_map->MinMyGID();
170 }
const Map * m_map
Map.
Definition: VectorSpace.h:153
int MinMyGID() const
The minimum global index value on the calling processor.
Definition: Map.C:118
template<class V , class M >
const std::string & QUESO::VectorSpace< V, M >::localComponentName ( unsigned int  localComponentId) const

Returns the local component names.

Definition at line 277 of file VectorSpace.C.

279 {
280  if (m_componentsNamesArray == NULL) return m_emptyComponentName;
281 
282  queso_require_less_equal_msg(localComponentId, m_dimLocal, "localComponentId is too big");
283 
284 //return (*(const_cast<DistArray<std::string>*>(m_componentsNamesArray)))(localComponentId,0);
285  return (*m_componentsNamesArray)(localComponentId,0);
286 }
std::string m_emptyComponentName
Empty string for the components names.
Definition: VectorSpace.h:165
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:156
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:159
template<class V , class M >
const Map & QUESO::VectorSpace< V, M >::map ( ) const

Map.

Definition at line 142 of file VectorSpace.C.

Referenced by QUESO::GPMSAFactory< V, M >::GPMSAFactory().

143 {
144  queso_require_msg(m_map, "m_map is still NULL");
145  return *m_map;
146 }
const Map * m_map
Map.
Definition: VectorSpace.h:153
template<class V , class M>
void QUESO::VectorSpace< V, M >::moments ( M &  vec) const
virtual

The (INFINITY/nonexistent) matrix of second moments of the space.

Implements QUESO::VectorSet< V, M >.

Definition at line 259 of file VectorSpace.C.

260 {
261  queso_assert_equal_to (m_dimLocal, mat.numCols());
262 
263  mat.zeroLower();
264  mat.zeroUpper();
265  for (unsigned int i = 0; i < m_dimLocal; ++i) {
266  mat(i,i) = INFINITY;
267  }
268 }
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:156
template<>
GslMatrix * QUESO::VectorSpace< GslVector, GslMatrix >::newDiagMatrix ( double  diagValue) const

Definition at line 60 of file GslVectorSpace.C.

61 {
62  return new GslMatrix(m_env,*m_map,diagValue);
63 }
const Map * m_map
Map.
Definition: VectorSpace.h:153
const BaseEnvironment & m_env
Definition: VectorSet.h:104
template<>
TeuchosMatrix * QUESO::VectorSpace< TeuchosVector, TeuchosMatrix >::newDiagMatrix ( double  diagValue) const

Definition at line 63 of file TeuchosVectorSpace.C.

64 {
65  return new TeuchosMatrix(m_env,*m_map,diagValue);
66 }
const Map * m_map
Map.
Definition: VectorSpace.h:153
const BaseEnvironment & m_env
Definition: VectorSet.h:104
template<class V, class M >
M * QUESO::VectorSpace< V, M >::newDiagMatrix ( const V &  v) const

Creates a diagonal matrix with the elements and size of vector v.

Definition at line 190 of file VectorSpace.C.

191 {
192  if (v.sizeGlobal() != m_dimGlobal) return NULL;
193  if (v.sizeLocal () != m_dimLocal ) return NULL;
194 
195  return new M(v);
196 }
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:156
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:150
template<class V, class M>
M* QUESO::VectorSpace< V, M >::newDiagMatrix ( double  diagValue) const

Creates a diagonal matrix with the elements diagValue and size given by Map& map. See template specialization.

template<>
Map * QUESO::VectorSpace< GslVector, GslMatrix >::newMap ( )
protected

Definition at line 32 of file GslVectorSpace.C.

33 {
34  return new Map(m_dimGlobal,0,m_env.selfComm());
35 }
const MpiComm & selfComm() const
Access function for MpiComm self-communicator.
Definition: Environment.C:300
const BaseEnvironment & m_env
Definition: VectorSet.h:104
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:150
template<>
Map * QUESO::VectorSpace< TeuchosVector, TeuchosMatrix >::newMap ( )
protected

Definition at line 35 of file TeuchosVectorSpace.C.

36 {
37  return new Map(m_dimGlobal,0,m_env.selfComm());
38 }
const MpiComm & selfComm() const
Access function for MpiComm self-communicator.
Definition: Environment.C:300
const BaseEnvironment & m_env
Definition: VectorSet.h:104
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:150
template<class V, class M>
Map* QUESO::VectorSpace< V, M >::newMap ( )
protected

Creates a new map. See template specialization.

template<>
GslMatrix * QUESO::VectorSpace< GslVector, GslMatrix >::newMatrix ( ) const

Definition at line 53 of file GslVectorSpace.C.

54 {
55  return new GslMatrix(m_env,*m_map,this->dimGlobal());
56 }
unsigned int dimGlobal() const
Definition: VectorSpace.C:161
const Map * m_map
Map.
Definition: VectorSpace.h:153
const BaseEnvironment & m_env
Definition: VectorSet.h:104
template<>
TeuchosMatrix * QUESO::VectorSpace< TeuchosVector, TeuchosMatrix >::newMatrix ( ) const

Definition at line 56 of file TeuchosVectorSpace.C.

57 {
58  return new TeuchosMatrix(m_env,*m_map,this->dimGlobal());
59 }
unsigned int dimGlobal() const
Definition: VectorSpace.C:161
const Map * m_map
Map.
Definition: VectorSpace.h:153
const BaseEnvironment & m_env
Definition: VectorSet.h:104
template<class V, class M>
M* QUESO::VectorSpace< V, M >::newMatrix ( ) const

Creates an empty matrix of size given by Map& map. See template specialization.

template<class V, class M >
M * QUESO::VectorSpace< V, M >::newProposalMatrix ( const V *  varVec,
const V *  auxVec 
) const

Creates a diagonal matrix conditionally to values from vector varVec, guaranteeing that its values are neither 0, NAN nor INFINITY.

If varVec[i] is either 0, NAN or INFINITY, then this method tries to assign the value (*auxVec)[i])^2 to matrix(i,i). Case (*auxVec)[i])^2 is either NAN or INFINITY, then matrix(i,i)=1.

Definition at line 199 of file VectorSpace.C.

200 {
201  V tmpVec(*m_zeroVector);
202  for (unsigned int i = 0; i < m_dimLocal; ++i) {
203  double variance = INFINITY;
204  if (varVec) variance = (*varVec)[i];
205  if (m_env.subDisplayFile()) {
206  *m_env.subDisplayFile() << "In VectorSpace<V,M>::newProposalMatrix()"
207  << ": i = " << i
208  << ", variance = " << variance
209  << std::endl;
210  }
211  if ((variance == INFINITY) ||
212  (variance == NAN )) {
213  if (auxVec) {
214  tmpVec[i] = std::pow( fabs((*auxVec)[i])*0.05,2. );
215  if ((tmpVec[i] == 0. ) ||
216  (tmpVec[i] == INFINITY) ||
217  (tmpVec[i] == NAN )) {
218  tmpVec[i] = 1.;
219  }
220  }
221  else {
222  tmpVec[i] = 1.;
223  }
224  }
225  else if (variance == 0.) {
226  tmpVec[i] = 1.;
227  }
228  else {
229  tmpVec[i] = variance;
230  }
231  }
232 
233  return newDiagMatrix(tmpVec);
234 }
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:156
const BaseEnvironment & m_env
Definition: VectorSet.h:104
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:168
M * newDiagMatrix(const V &v) const
Creates a diagonal matrix with the elements and size of vector v.
Definition: VectorSpace.C:190
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<>
GslVector * QUESO::VectorSpace< GslVector, GslMatrix >::newVector ( ) const

Definition at line 39 of file GslVectorSpace.C.

40 {
41  return new GslVector(m_env,*m_map);
42 }
const Map * m_map
Map.
Definition: VectorSpace.h:153
const BaseEnvironment & m_env
Definition: VectorSet.h:104
template<>
TeuchosVector * QUESO::VectorSpace< TeuchosVector, TeuchosMatrix >::newVector ( ) const

Definition at line 42 of file TeuchosVectorSpace.C.

43 {
44  return new TeuchosVector(m_env,*m_map);
45 }
const Map * m_map
Map.
Definition: VectorSpace.h:153
const BaseEnvironment & m_env
Definition: VectorSet.h:104
template<>
GslVector * QUESO::VectorSpace< GslVector, GslMatrix >::newVector ( double  value) const

Definition at line 46 of file GslVectorSpace.C.

47 {
48  return new GslVector(m_env,*m_map,value);
49 }
const Map * m_map
Map.
Definition: VectorSpace.h:153
const BaseEnvironment & m_env
Definition: VectorSet.h:104
template<>
TeuchosVector * QUESO::VectorSpace< TeuchosVector, TeuchosMatrix >::newVector ( double  value) const

Definition at line 49 of file TeuchosVectorSpace.C.

50 {
51  return new TeuchosVector(m_env,*m_map,value);
52 }
const Map * m_map
Map.
Definition: VectorSpace.h:153
const BaseEnvironment & m_env
Definition: VectorSet.h:104
template<class V, class M>
V* QUESO::VectorSpace< V, M >::newVector ( ) const

Creates an empty vector of size given by Map& map. See template specialization.

template<class V, class M>
V* QUESO::VectorSpace< V, M >::newVector ( double  value) const

Creates a vector of size given by Map& map and all values give by value. See template specialization.

template<class V, class M >
V * QUESO::VectorSpace< V, M >::newVector ( const V &  v) const

Creates vector as a copy of another.

Definition at line 181 of file VectorSpace.C.

182 {
183  if (v.sizeGlobal() != m_dimGlobal) return NULL;
184  if (v.sizeLocal () != m_dimLocal ) return NULL;
185 
186  return new V(v);
187 }
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:156
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:150
template<class V , class M >
unsigned int QUESO::VectorSpace< V, M >::numOfProcsForStorage ( ) const

Returns total number of processes.

Definition at line 149 of file VectorSpace.C.

Referenced by QUESO::ComputeCovCorrMatricesBetweenVectorRvs(), and QUESO::ComputeCovCorrMatricesBetweenVectorSequences().

150 {
151  return m_map->Comm().NumProc();
152 }
const Map * m_map
Map.
Definition: VectorSpace.h:153
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:133
const MpiComm & Comm() const
Access function for MpiComm communicator.
Definition: Map.C:131
template<class V , class M >
void QUESO::VectorSpace< V, M >::print ( std::ostream &  os) const
virtual

Prints only a message.

Reimplemented from QUESO::VectorSet< V, M >.

Definition at line 309 of file VectorSpace.C.

310 {
311  os << "In VectorSpace<V,M>::print()"
312  << ": nothing to be printed" << std::endl;
313  return;
314 }
template<class V , class M >
void QUESO::VectorSpace< V, M >::printComponentsNames ( std::ostream &  os,
bool  printHorizontally 
) const

Prints the local component names.

Definition at line 289 of file VectorSpace.C.

291 {
292  if (printHorizontally) {
293  for (unsigned int i = 0; i < this->dimLocal(); ++i) {
294  os << "'" << this->localComponentName(i) << "'"
295  << " ";
296  }
297  }
298  else {
299  for (unsigned int i = 0; i < this->dimLocal(); ++i) {
300  os << "'" << this->localComponentName(i) << "'"
301  << std::endl;
302  }
303  }
304 
305  return;
306 }
const std::string & localComponentName(unsigned int localComponentId) const
Returns the local component names.
Definition: VectorSpace.C:277
unsigned int dimLocal() const
Definition: VectorSpace.C:155
template<class V , class M >
const VectorSpace< V, M > & QUESO::VectorSpace< V, M >::vectorSpace ( ) const
virtual

Accessor method to this. Vector space to which this vector set belongs to.

It is virtual in the base class 'VectorSet'

Implements QUESO::VectorSet< V, M >.

Definition at line 237 of file VectorSpace.C.

238 {
239  return *this;
240 }
template<class V , class M >
const V & QUESO::VectorSpace< V, M >::zeroVector ( ) const

Returns a vector filled with zeros.

Definition at line 174 of file VectorSpace.C.

Referenced by QUESO::ComputeCovCorrMatricesBetweenVectorRvs(), and QUESO::ComputeCovCorrMatricesBetweenVectorSequences().

175 {
176  queso_require_msg(m_zeroVector, "m_zeroVector is still NULL");
177  return *m_zeroVector;
178 }
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:168

Member Data Documentation

template<class V, class M>
DistArray<std::string>* QUESO::VectorSpace< V, M >::m_componentsNamesArray
protected

Array of strings of the type DistArray to store the names of the components.

Definition at line 159 of file VectorSpace.h.

Referenced by QUESO::VectorSpace< V, M >::VectorSpace().

template<class V, class M>
DistArray<std::string>* QUESO::VectorSpace< V, M >::m_componentsNamesVec
protected

Vector of strings of the type DistArray to store the names of the components.

Definition at line 162 of file VectorSpace.h.

template<class V, class M>
unsigned int QUESO::VectorSpace< V, M >::m_dimGlobal
protected

Global dimension.

Definition at line 150 of file VectorSpace.h.

Referenced by QUESO::VectorSpace< V, M >::VectorSpace().

template<class V, class M>
unsigned int QUESO::VectorSpace< V, M >::m_dimLocal
protected

Local dimension (number of elements owned by the calling processor.).

Definition at line 156 of file VectorSpace.h.

Referenced by QUESO::VectorSpace< V, M >::VectorSpace().

template<class V, class M>
std::string QUESO::VectorSpace< V, M >::m_emptyComponentName
protected

Empty string for the components names.

Definition at line 165 of file VectorSpace.h.

template<class V, class M>
const Map* QUESO::VectorSpace< V, M >::m_map
protected

Map.

Definition at line 153 of file VectorSpace.h.

Referenced by QUESO::VectorSpace< V, M >::VectorSpace().

template<class V, class M>
V* QUESO::VectorSpace< V, M >::m_zeroVector
protected

A vector of all elements equal to zero.

Definition at line 168 of file VectorSpace.h.

Referenced by QUESO::VectorSpace< V, M >::VectorSpace().


The documentation for this class was generated from the following files:

Generated on Tue Jun 5 2018 19:49:02 for queso-0.57.1 by  doxygen 1.8.5