queso-0.56.1
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-2015 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(const VectorSpace<V,M>& aux);
62 
64  ~VectorSpace();
66 
67 
69 
70  const BaseEnvironment& env () const;
72 
74  const Map& map () const;
75 
77  unsigned int numOfProcsForStorage () const;
78 
79 
80  unsigned int dimLocal () const;
81  unsigned int dimGlobal () const;
82  unsigned int globalIdOfFirstComponent() const;
84 
86 
87  const V& zeroVector () const;
89 
91  V* newVector () const; // See template specialization
92 
94  V* newVector (double value) const; // See template specialization
95 
97  V* newVector (const V& v) const;
98 
100  M* newMatrix () const; // See template specialization
101 
103  M* newDiagMatrix (const V& v) const;
104 
106  M* newDiagMatrix (double diagValue) const; // See template specialization
107 
109 
111  M* newProposalMatrix (const V* varVec, const V* auxVec) const;
112 
114 
115  const VectorSpace<V,M>& vectorSpace () const; //
116 
118  bool contains (const V& vec) const;
119 
121  void centroid (V& vec) const;
122 
124  void moments (M& vec) const;
125 
127  const DistArray<std::string>* componentsNamesArray () const;
128 
130  const std::vector<std::string>* componentsNamesVec () const;
131 
133  const std::string& localComponentName (unsigned int localComponentId) const;
135 
137 
138  void printComponentsNames (std::ostream& os, bool printHorizontally) const;
140 
142  void print (std::ostream& os) const;
144 protected:
146  Map* newMap (); // See template specialization
147 
148  using VectorSet<V,M>::m_env;
149  using VectorSet<V,M>::m_prefix;
150  using VectorSet<V,M>::m_volume;
151 
153  unsigned int m_dimGlobal;
154 
156  const Map* m_map;
157 
159  unsigned int m_dimLocal;
160 
163 
166 
168  std::string m_emptyComponentName;
169 
172 
173 private:
175  VectorSpace();
176 };
177 
178 } // End namespace QUESO
179 
180 #endif // UQ_VECTOR_SPACE_H
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:153
Map * newMap()
Creates a new map. See template specialization.
const Map & map() const
Map.
Definition: VectorSpace.C:157
void print(std::ostream &os) const
Prints only a message.
Definition: VectorSpace.C:324
const std::vector< std::string > * componentsNamesVec() const
Access to private attribute m_componentsNamesVec.
~VectorSpace()
Destructor.
Definition: VectorSpace.C:131
std::string m_emptyComponentName
Empty string for the components names.
Definition: VectorSpace.h:168
const Map * m_map
Map.
Definition: VectorSpace.h:156
void printComponentsNames(std::ostream &os, bool printHorizontally) const
Prints the local component names.
Definition: VectorSpace.C:304
unsigned int globalIdOfFirstComponent() const
Definition: VectorSpace.C:182
A class for partitioning vectors and matrices.
Definition: Map.h:49
const V & zeroVector() const
Returns a vector filled with zeros.
Definition: VectorSpace.C:189
M * newMatrix() const
Creates an empty matrix of size given by Map&amp; map. See template specialization.
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:171
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:159
const std::string & localComponentName(unsigned int localComponentId) const
Returns the local component names.
Definition: VectorSpace.C:292
void moments(M &vec) const
The (INFINITY/nonexistent) matrix of second moments of the space.
Definition: VectorSpace.C:274
VectorSpace()
Default constructor.
DistArray< std::string > * m_componentsNamesVec
Vector of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:165
const BaseEnvironment & env() const
Environment.
Definition: VectorSpace.C:151
const std::string & prefix() const
Access to private attribute m_prefix.
Definition: VectorSet.C:84
bool contains(const V &vec) const
Whether vector contains vector vec.
Definition: VectorSpace.C:258
unsigned int dimGlobal() const
Definition: VectorSpace.C:176
V * newVector() const
Creates an empty vector of size given by Map&amp; map. See template specialization.
M * newDiagMatrix(const V &v) const
Creates a diagonal matrix with the elements and size of vector v.
Definition: VectorSpace.C:205
void centroid(V &vec) const
The (INFINITY/nonexistent) centroid of the space.
Definition: VectorSpace.C:264
const DistArray< std::string > * componentsNamesArray() const
Access to private attribute m_componentsNamesArray, which is an instance of DistArray.
Definition: VectorSpace.C:286
unsigned int numOfProcsForStorage() const
Returns total number of processes.
Definition: VectorSpace.C:164
DistArray< std::string > * m_componentsNamesArray
Array of strings of the type DistArray to store the names of the components.
Definition: VectorSpace.h:162
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:214
const VectorSpace< V, M > & vectorSpace() const
Accessor method to this. Vector space to which this vector set belongs to.
Definition: VectorSpace.C:252
unsigned int dimLocal() const
Definition: VectorSpace.C:170

Generated on Thu Dec 15 2016 13:23:09 for queso-0.56.1 by  doxygen 1.8.5