queso-0.51.1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QUESO::VectorSpace< V, M > Class Template Reference

A class representing a vector space. More...

#include <VectorSet.h>

Inheritance diagram for QUESO::VectorSpace< V, M >:
Inheritance graph
[legend]
Collaboration diagram for QUESO::VectorSpace< V, M >:
Collaboration graph
[legend]

Public Member Functions

template<>
GslVectornewVector () const
 
template<>
GslVectornewVector (double value) const
 
template<>
GslMatrixnewMatrix () const
 
template<>
GslMatrixnewDiagMatrix (double diagValue) const
 
Constructor/Destructor methods
 VectorSpace ()
 Default constructor. More...
 
 VectorSpace (const BaseEnvironment &env, const char *prefix, unsigned int dimGlobalValue, const std::vector< std::string > *componentsNamesVec)
 Shaped constructor. More...
 
 VectorSpace (const VectorSpace< V, M > &aux)
 Copy 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...
 
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 ()
 Default Constructor. More...
 
 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 ()
 

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
 

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 46 of file VectorSet.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 38 of file VectorSpace.C.

References QUESO::VectorSet< V, M >::m_env, UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

39  : VectorSet<V,M>()
40 {
42  m_env.worldRank(),
43  "VectorSpace<V,M>::constructor(), default",
44  "should not be used by user");
45 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const BaseEnvironment & m_env
Definition: VectorSet.h:99
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
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 49 of file VectorSpace.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::VectorSpace< V, M >::globalIdOfFirstComponent(), 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::Map::NumGlobalElements(), QUESO::BaseEnvironment::subDisplayFile(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

52  : VectorSet<V,M> (env,((std::string)(prefix) + "space_").c_str(),INFINITY),
53  m_dimGlobal(dimGlobalValue),
54  m_map(newMap()),
59  m_zeroVector(new V(m_env,*m_map))
60 {
61  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
62  *m_env.subDisplayFile() << "Entering VectorSpace<V,M>::constructor(1)"
63  << ", with m_prefix = " << m_prefix
64  << "\n m_zeroVector->sizeGlobal() = " << m_zeroVector->sizeGlobal()
65  << "\n m_dimGlobal = " << m_dimGlobal
66  << "\n m_zeroVector->sizeLocal() = " << m_zeroVector->sizeLocal()
67  << "\n m_dimLocal = " << m_dimLocal
68  << "\n m_map->NumGlobalElements() = " << m_map->NumGlobalElements()
69  << "\n componentsNamesVec = " << componentsNamesVec
70  << std::endl;
71  }
72 
73  if (m_zeroVector->sizeGlobal() != m_dimGlobal) {
74  std::cerr << "In VectorSpace<V,M>::constructor(1)"
75  << ", with m_prefix = " << m_prefix
76  << ": m_zeroVector->sizeGlobal() = " << m_zeroVector->sizeGlobal()
77  << ", m_dimGlobal = " << m_dimGlobal
78  << std::endl;
79  }
80  UQ_FATAL_TEST_MACRO((m_zeroVector->sizeGlobal() != m_dimGlobal),
81  m_env.worldRank(),
82  "VectorSpace<V,M>::constructor(1)",
83  "global size of 'm_zeroVector' is not equal to m_dimGlobal");
84 
85  if (m_zeroVector->sizeLocal() != m_dimLocal) {
86  std::cerr << "In VectorSpace<V,M>::constructor(1)"
87  << ", with m_prefix = " << m_prefix
88  << ": m_zeroVector->sizeLocal() = " << m_zeroVector->sizeLocal()
89  << ", m_dimLocal = " << m_dimLocal
90  << std::endl;
91  }
93  m_env.worldRank(),
94  "VectorSpace<V,M>::constructor(1)",
95  "local size of 'm_zeroVector' is not equal to m_dimLocal");
96 
97  if (componentsNamesVec != NULL) {
99  m_env.worldRank(),
100  "VectorSpace<V,M>::constructor(1)",
101  "global size of 'componentsNames' is not equal to m_dimGlobal");
102 
103  m_componentsNamesArray = new DistArray<std::string>(*m_map,1);
104  unsigned int myFirstId = this->globalIdOfFirstComponent();
105  for (unsigned int i = 0; i < m_dimLocal; ++i) {
106  (*m_componentsNamesArray)(i,0) = (*componentsNamesVec)[myFirstId+i];
107  }
108 
109  UQ_FATAL_TEST_MACRO((m_componentsNamesArray->GlobalLength() != (int) m_dimGlobal),
110  m_env.worldRank(),
111  "VectorSpace<V,M>::constructor(1)",
112  "global size of 'm_componentsNamesArray' is not equal to m_dimGlobal");
113  UQ_FATAL_TEST_MACRO((m_componentsNamesArray->MyLength() != (int) m_dimLocal),
114  m_env.worldRank(),
115  "VectorSpace<V,M>::constructor(1)",
116  "local size of 'm_componentsNamesArray' is not equal to m_dimLocal");
117  }
118 
119  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
120  *m_env.subDisplayFile() << "Leaving VectorSpace<V,M>::constructor(1)"
121  << ", with m_prefix = " << m_prefix
122  << std::endl;
123  }
124 }
const std::string & prefix() const
Access to private attribute m_prefix.
Definition: VectorSet.C:88
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:156
std::string m_emptyComponentName
Empty string for the components names.
Definition: VectorSpace.h:162
const std::vector< std::string > * componentsNamesVec() const
Access to private attribute m_componentsNamesVec.
unsigned int globalIdOfFirstComponent() const
Definition: VectorSpace.C:211
const BaseEnvironment & env() const
Environment.
Definition: VectorSpace.C:177
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:147
Map * newMap()
Creates a new map. See template specialization.
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:165
const BaseEnvironment & m_env
Definition: VectorSet.h:99
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:118
std::string m_prefix
Definition: VectorSet.h:100
DistArray< std::string > * m_componentsNamesVec
Vector 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:96
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:153
unsigned int displayVerbosity() const
Definition: Environment.C:436
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
const Map * m_map
Map.
Definition: VectorSpace.h:150
template<class V, class M>
QUESO::VectorSpace< V, M >::VectorSpace ( const VectorSpace< V, M > &  aux)

Copy constructor.

Definition at line 128 of file VectorSpace.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::VectorSpace< V, M >::m_componentsNamesArray, QUESO::VectorSpace< V, M >::m_componentsNamesVec, QUESO::VectorSet< V, M >::m_env, and QUESO::BaseEnvironment::subDisplayFile().

129  : VectorSet<V,M>(aux.env(),((std::string)(aux.m_prefix)).c_str(),INFINITY),
130  m_dimGlobal(aux.m_dimGlobal),
131  m_map(newMap()),
134  m_componentsNamesVec(NULL),
136  m_zeroVector(new V(m_env,*m_map))
137 {
138  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
139  *m_env.subDisplayFile() << "Entering VectorSpace<V,M>::constructor(2)"
140  << ": aux.m_componentsNamesArray = " << aux.m_componentsNamesArray
141  << ", aux.m_componentsNamesVec = " << aux.m_componentsNamesVec
142  << std::endl;
143  }
144 
145  if (aux.m_componentsNamesArray != NULL) {
146  m_componentsNamesArray = new DistArray<std::string>(*(aux.m_componentsNamesArray));
147  }
148 
149  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
150  *m_env.subDisplayFile() << "Leaving VectorSpace<V,M>::constructor(2)"
151  << std::endl;
152  }
153 }
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:156
std::string m_emptyComponentName
Empty string for the components names.
Definition: VectorSpace.h:162
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:147
Map * newMap()
Creates a new map. See template specialization.
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:165
const BaseEnvironment & m_env
Definition: VectorSet.h:99
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:118
DistArray< std::string > * m_componentsNamesVec
Vector of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:159
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:153
unsigned int displayVerbosity() const
Definition: Environment.C:436
const Map * m_map
Map.
Definition: VectorSpace.h:150
template<class V , class M >
QUESO::VectorSpace< V, M >::~VectorSpace ( )

Destructor.

Definition at line 157 of file VectorSpace.C.

158 {
159  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
160  *m_env.subDisplayFile() << "Entering VectorSpace<V,M>::destructor()"
161  << std::endl;
162  }
163 
164  if (m_zeroVector != NULL) delete m_zeroVector;
165  if (m_componentsNamesVec != NULL) delete m_componentsNamesVec;
167  if (m_map != NULL) delete m_map;
168 
169  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
170  *m_env.subDisplayFile() << "Leaving VectorSpace<V,M>::destructor()"
171  << std::endl;
172  }
173 }
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:156
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:165
const BaseEnvironment & m_env
Definition: VectorSet.h:99
DistArray< std::string > * m_componentsNamesVec
Vector of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:159
unsigned int displayVerbosity() const
Definition: Environment.C:436
const Map * m_map
Map.
Definition: VectorSpace.h:150

Member Function Documentation

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 297 of file VectorSpace.C.

298 {
299  return m_componentsNamesArray;
300 }
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:156
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 290 of file VectorSpace.C.

291 {
292  if (vec[0]) {}; // just to remove compiler warning
293  return true;
294 }
template<class V , class M >
unsigned int QUESO::VectorSpace< V, M >::dimGlobal ( ) const

Definition at line 205 of file VectorSpace.C.

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

206 {
207  return m_dimGlobal;
208 }
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:147
template<class V , class M >
unsigned int QUESO::VectorSpace< V, M >::dimLocal ( ) const
template<class V , class M >
const BaseEnvironment & QUESO::VectorSpace< V, M >::env ( ) const

Environment.

Definition at line 177 of file VectorSpace.C.

Referenced by QUESO::InstantiateIntersection().

178 {
179  return m_env;
180 }
const BaseEnvironment & m_env
Definition: VectorSet.h:99
template<class V , class M >
unsigned int QUESO::VectorSpace< V, M >::globalIdOfFirstComponent ( ) const

Definition at line 211 of file VectorSpace.C.

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

212 {
213  return m_map->MinMyGID();
214 }
int MinMyGID() const
The minimum global index value on the calling processor.
Definition: Map.C:129
const Map * m_map
Map.
Definition: VectorSpace.h:150
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 303 of file VectorSpace.C.

References UQ_FATAL_TEST_MACRO.

305 {
306  if (m_componentsNamesArray == NULL) return m_emptyComponentName;
307 
308  UQ_FATAL_TEST_MACRO(localComponentId > m_dimLocal,
309  m_env.worldRank(),
310  "VectorSpace<V,M>::localComponentName()",
311  "localComponentId is too big");
312 
313 //return (*(const_cast<DistArray<std::string>*>(m_componentsNamesArray)))(localComponentId,0);
314  return (*m_componentsNamesArray)(localComponentId,0);
315 }
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:156
std::string m_emptyComponentName
Empty string for the components names.
Definition: VectorSpace.h:162
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const BaseEnvironment & m_env
Definition: VectorSet.h:99
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:153
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
template<class V , class M >
const Map & QUESO::VectorSpace< V, M >::map ( ) const

Map.

Definition at line 183 of file VectorSpace.C.

References UQ_FATAL_TEST_MACRO.

184 {
185  UQ_FATAL_TEST_MACRO(m_map == NULL,
186  m_env.worldRank(),
187  "VectorSpace<V,M>::map()",
188  "m_map is still NULL");
189  return *m_map;
190 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const BaseEnvironment & m_env
Definition: VectorSet.h:99
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
const Map * m_map
Map.
Definition: VectorSpace.h:150
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 BaseEnvironment & m_env
Definition: VectorSet.h:99
const Map * m_map
Map.
Definition: VectorSpace.h:150
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 237 of file VectorSpace.C.

238 {
239  if (v.sizeGlobal() != m_dimGlobal) return NULL;
240  if (v.sizeLocal () != m_dimLocal ) return NULL;
241 
242  return new M(v);
243 }
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:147
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:153
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 }
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:147
const BaseEnvironment & m_env
Definition: VectorSet.h:99
const MpiComm & selfComm() const
Access function for MpiComm self-communicator.
Definition: Environment.C:279
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 }
const BaseEnvironment & m_env
Definition: VectorSet.h:99
unsigned int dimGlobal() const
Definition: VectorSpace.C:205
const Map * m_map
Map.
Definition: VectorSpace.h:150
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 246 of file VectorSpace.C.

247 {
248  V tmpVec(*m_zeroVector);
249  for (unsigned int i = 0; i < m_dimLocal; ++i) {
250  double variance = INFINITY;
251  if (varVec) variance = (*varVec)[i];
252  if (m_env.subDisplayFile()) {
253  *m_env.subDisplayFile() << "In VectorSpace<V,M>::newProposalMatrix()"
254  << ": i = " << i
255  << ", variance = " << variance
256  << std::endl;
257  }
258  if ((variance == INFINITY) ||
259  (variance == NAN )) {
260  if (auxVec) {
261  tmpVec[i] = std::pow( fabs((*auxVec)[i])*0.05,2. );
262  if ((tmpVec[i] == 0. ) ||
263  (tmpVec[i] == INFINITY) ||
264  (tmpVec[i] == NAN )) {
265  tmpVec[i] = 1.;
266  }
267  }
268  else {
269  tmpVec[i] = 1.;
270  }
271  }
272  else if (variance == 0.) {
273  tmpVec[i] = 1.;
274  }
275  else {
276  tmpVec[i] = variance;
277  }
278  }
279 
280  return newDiagMatrix(tmpVec);
281 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:165
const BaseEnvironment & m_env
Definition: VectorSet.h:99
M * newDiagMatrix(const V &v) const
Creates a diagonal matrix with the elements and size of vector v.
Definition: VectorSpace.C:237
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:153
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 BaseEnvironment & m_env
Definition: VectorSet.h:99
const Map * m_map
Map.
Definition: VectorSpace.h:150
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 BaseEnvironment & m_env
Definition: VectorSet.h:99
const Map * m_map
Map.
Definition: VectorSpace.h:150
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 228 of file VectorSpace.C.

229 {
230  if (v.sizeGlobal() != m_dimGlobal) return NULL;
231  if (v.sizeLocal () != m_dimLocal ) return NULL;
232 
233  return new V(v);
234 }
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:147
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:153
template<class V , class M >
unsigned int QUESO::VectorSpace< V, M >::numOfProcsForStorage ( ) const

Returns total number of processes.

Definition at line 193 of file VectorSpace.C.

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

194 {
195  return m_map->Comm().NumProc();
196 }
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:121
const MpiComm & Comm() const
Access function for MpiComm communicator.
Definition: Map.C:142
const Map * m_map
Map.
Definition: VectorSpace.h:150
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 338 of file VectorSpace.C.

339 {
340  os << "In VectorSpace<V,M>::print()"
341  << ": nothing to be printed" << std::endl;
342  return;
343 }
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 318 of file VectorSpace.C.

320 {
321  if (printHorizontally) {
322  for (unsigned int i = 0; i < this->dimLocal(); ++i) {
323  os << "'" << this->localComponentName(i) << "'"
324  << " ";
325  }
326  }
327  else {
328  for (unsigned int i = 0; i < this->dimLocal(); ++i) {
329  os << "'" << this->localComponentName(i) << "'"
330  << std::endl;
331  }
332  }
333 
334  return;
335 }
unsigned int dimLocal() const
Definition: VectorSpace.C:199
const std::string & localComponentName(unsigned int localComponentId) const
Returns the local component names.
Definition: VectorSpace.C:303
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 284 of file VectorSpace.C.

285 {
286  return *this;
287 }
template<class V , class M >
const V & QUESO::VectorSpace< V, M >::zeroVector ( ) const

Returns a vector filled with zeros.

Definition at line 218 of file VectorSpace.C.

References UQ_FATAL_TEST_MACRO.

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

219 {
221  m_env.worldRank(),
222  "VectorSpace<V,M>::zeroVector()",
223  "m_zeroVector is still NULL");
224  return *m_zeroVector;
225 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:165
const BaseEnvironment & m_env
Definition: VectorSet.h:99
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223

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 156 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 159 of file VectorSpace.h.

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

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

Global dimension.

Definition at line 147 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 153 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 162 of file VectorSpace.h.

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

Map.

Definition at line 150 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 165 of file VectorSpace.h.

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


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

Generated on Thu Apr 23 2015 19:26:17 for queso-0.51.1 by  doxygen 1.8.5