queso-0.57.0
VectorSpace.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2017 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #ifndef UQ_VECTOR_SPACE_H
26 #define UQ_VECTOR_SPACE_H
27 
28 #include <queso/DistArray.h>
29 #include <queso/Map.h>
30 #include <queso/VectorSet.h>
31 #include <cmath>
32 
33 namespace QUESO {
34 
35 class GslVector;
36 class GslMatrix;
37 
46 template <class V = GslVector, class M = GslMatrix>
47 class VectorSpace : public VectorSet<V,M>
48 {
49 public:
51 
52 
54 
55  VectorSpace(const BaseEnvironment& env,
56  const char* prefix,
57  unsigned int dimGlobalValue,
58  const std::vector<std::string>* componentsNamesVec);
59 
61  ~VectorSpace();
63 
64 
66 
67  const BaseEnvironment& env () const;
69 
71  const Map& map () const;
72 
74  unsigned int numOfProcsForStorage () const;
75 
76 
77  unsigned int dimLocal () const;
78  unsigned int dimGlobal () const;
79  unsigned int globalIdOfFirstComponent() const;
81 
83 
84  const V& zeroVector () const;
86 
88  V* newVector () const; // See template specialization
89 
91  V* newVector (double value) const; // See template specialization
92 
94  V* newVector (const V& v) const;
95 
97  M* newMatrix () const; // See template specialization
98 
100  M* newDiagMatrix (const V& v) const;
101 
103  M* newDiagMatrix (double diagValue) const; // See template specialization
104 
106 
108  M* newProposalMatrix (const V* varVec, const V* auxVec) const;
109 
111 
112  const VectorSpace<V,M>& vectorSpace () const; //
113 
115  bool contains (const V& vec) const;
116 
118  void centroid (V& vec) const;
119 
121  void moments (M& vec) const;
122 
124  const DistArray<std::string>* componentsNamesArray () const;
125 
127  const std::vector<std::string>* componentsNamesVec () const;
128 
130  const std::string& localComponentName (unsigned int localComponentId) const;
132 
134 
135  void printComponentsNames (std::ostream& os, bool printHorizontally) const;
137 
139  void print (std::ostream& os) const;
141 protected:
143  Map* newMap (); // See template specialization
144 
145  using VectorSet<V,M>::m_env;
146  using VectorSet<V,M>::m_prefix;
147  using VectorSet<V,M>::m_volume;
148 
150  unsigned int m_dimGlobal;
151 
153  const Map* m_map;
154 
156  unsigned int m_dimLocal;
157 
160 
163 
165  std::string m_emptyComponentName;
166 
169 
170 private:
172  VectorSpace();
173 
175  VectorSpace(const VectorSpace<V,M>& aux);
176 };
177 
178 } // End namespace QUESO
179 
180 #endif // UQ_VECTOR_SPACE_H
void moments(M &vec) const
The (INFINITY/nonexistent) matrix of second moments of the space.
Definition: VectorSpace.C:259
const Map * m_map
Map.
Definition: VectorSpace.h:153
unsigned int numOfProcsForStorage() const
Returns total number of processes.
Definition: VectorSpace.C:149
unsigned int globalIdOfFirstComponent() const
Definition: VectorSpace.C:167
void centroid(V &vec) const
The (INFINITY/nonexistent) centroid of the space.
Definition: VectorSpace.C:249
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:156
const Map & map() const
Map.
Definition: VectorSpace.C:142
A class for partitioning vectors and matrices.
Definition: Map.h:49
const DistArray< std::string > * componentsNamesArray() const
Access to private attribute m_componentsNamesArray, which is an instance of DistArray.
Definition: VectorSpace.C:271
A class representing a vector space.
Definition: VectorSet.h:49
M * newDiagMatrix(const V &v) const
Creates a diagonal matrix with the elements and size of vector v.
Definition: VectorSpace.C:190
unsigned int dimGlobal() const
Definition: VectorSpace.C:161
M * newProposalMatrix(const V *varVec, const V *auxVec) const
Creates a diagonal matrix conditionally to values from vector varVec, guaranteeing that its values ar...
Definition: VectorSpace.C:199
DistArray< std::string > * m_componentsNamesVec
Vector of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:162
const V & zeroVector() const
Returns a vector filled with zeros.
Definition: VectorSpace.C:174
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:159
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:150
const VectorSpace< V, M > & vectorSpace() const
Accessor method to this. Vector space to which this vector set belongs to.
Definition: VectorSpace.C:237
const std::vector< std::string > * componentsNamesVec() const
Access to private attribute m_componentsNamesVec.
void printComponentsNames(std::ostream &os, bool printHorizontally) const
Prints the local component names.
Definition: VectorSpace.C:289
const std::string & localComponentName(unsigned int localComponentId) const
Returns the local component names.
Definition: VectorSpace.C:277
VectorSpace()
Default constructor.
unsigned int dimLocal() const
Definition: VectorSpace.C:155
~VectorSpace()
Destructor.
Definition: VectorSpace.C:116
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:168
Map * newMap()
Creates a new map. See template specialization.
void print(std::ostream &os) const
Prints only a message.
Definition: VectorSpace.C:309
const BaseEnvironment & env() const
Environment.
Definition: VectorSpace.C:136
V * newVector() const
Creates an empty vector of size given by Map&amp; map. See template specialization.
bool contains(const V &vec) const
Whether vector contains vector vec.
Definition: VectorSpace.C:243
const std::string & prefix() const
Access to private attribute m_prefix.
Definition: VectorSet.C:84
M * newMatrix() const
Creates an empty matrix of size given by Map&amp; map. See template specialization.
std::string m_emptyComponentName
Empty string for the components names.
Definition: VectorSpace.h:165

Generated on Sat Apr 22 2017 14:04:35 for queso-0.57.0 by  doxygen 1.8.5