queso-0.53.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-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  const DistArray<std::string>* componentsNamesArray () const;
122 
124  const std::vector<std::string>* componentsNamesVec () const;
125 
127  const std::string& localComponentName (unsigned int localComponentId) const;
129 
131 
132  void printComponentsNames (std::ostream& os, bool printHorizontally) const;
134 
136  void print (std::ostream& os) const;
138 protected:
140  Map* newMap (); // See template specialization
141 
142  using VectorSet<V,M>::m_env;
143  using VectorSet<V,M>::m_prefix;
144  using VectorSet<V,M>::m_volume;
145 
147  unsigned int m_dimGlobal;
148 
150  const Map* m_map;
151 
153  unsigned int m_dimLocal;
154 
157 
160 
162  std::string m_emptyComponentName;
163 
166 
167 private:
169  VectorSpace();
170 };
171 
172 } // End namespace QUESO
173 
174 #endif // UQ_VECTOR_SPACE_H
unsigned int dimLocal() const
Definition: VectorSpace.C:170
void printComponentsNames(std::ostream &os, bool printHorizontally) const
Prints the local component names.
Definition: VectorSpace.C:283
const VectorSpace< V, M > & vectorSpace() const
Accessor method to this. Vector space to which this vector set belongs to.
Definition: VectorSpace.C:252
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.
void print(std::ostream &os) const
Prints only a message.
Definition: VectorSpace.C:303
const Map & map() const
Map.
Definition: VectorSpace.C:157
unsigned int m_dimGlobal
Global dimension.
Definition: VectorSpace.h:147
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:159
const Map * m_map
Map.
Definition: VectorSpace.h:150
M * newMatrix() const
Creates an empty matrix of size given by Map&amp; map. See template specialization.
const V & zeroVector() const
Returns a vector filled with zeros.
Definition: VectorSpace.C:189
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.
unsigned int globalIdOfFirstComponent() const
Definition: VectorSpace.C:182
const std::string & localComponentName(unsigned int localComponentId) const
Returns the local component names.
Definition: VectorSpace.C:271
V * m_zeroVector
A vector of all elements equal to zero.
Definition: VectorSpace.h:165
const BaseEnvironment & env() const
Environment.
Definition: VectorSpace.C:151
M * newDiagMatrix(const V &v) const
Creates a diagonal matrix with the elements and size of vector v.
Definition: VectorSpace.C:205
const DistArray< std::string > * componentsNamesArray() const
Access to private attribute m_componentsNamesArray, which is an instance of DistArray.
Definition: VectorSpace.C:265
unsigned int m_dimLocal
Local dimension (number of elements owned by the calling processor.).
Definition: VectorSpace.h:153
Map * newMap()
Creates a new map. See template specialization.
~VectorSpace()
Destructor.
Definition: VectorSpace.C:131
bool contains(const V &vec) const
Whether vector contains vector vec.
Definition: VectorSpace.C:258
A class for partitioning vectors and matrices.
Definition: Map.h:49
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 std::string & prefix() const
Access to private attribute m_prefix.
Definition: VectorSet.C:84
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:156

Generated on Thu Jun 11 2015 13:52:31 for queso-0.53.0 by  doxygen 1.8.5