queso-0.51.1
Vector.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,2009,2010,2011,2012,2013 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_H
26 #define UQ_VECTOR_H
27 
28 #include <queso/Environment.h>
29 #include <queso/Map.h>
30 #include <iostream>
31 #include <queso/Defines.h>
32 
33 namespace QUESO {
34 
47 class Vector
48 {
49 public:
50 
52 
53  Vector();
55 
57  Vector(const BaseEnvironment& env, const Map& map);
58 
60  Vector(const Vector& rhs);
61 
63  virtual ~Vector();
65 
67 
68 
70  Vector& operator=(const Vector& rhs);
71 
73  Vector& operator*=(double a);
74 
76  Vector& operator/=(double a);
77 
79  Vector& operator+=(const Vector& rhs);
80 
82  Vector& operator-=(const Vector& rhs);
84 
86 
87  const BaseEnvironment& env () const;
88  const Map& map () const;
89  unsigned int numOfProcsForStorage() const;
91 
93 
94  virtual unsigned int sizeLocal () const = 0;
96 
98  virtual unsigned int sizeGlobal () const = 0;
100 
102 
103  virtual void cwSet (double value) = 0;
105 
107  virtual void cwSetGaussian (double mean, double stdDev) = 0;
108 
110  virtual void cwInvert () = 0;
112 
113 
115 
116  virtual void sort () = 0;
118 
120  virtual void print (std::ostream& os) const = 0;
121 
123  void setPrintHorizontally(bool value) const; // Yes, 'const'
124 
126  bool getPrintHorizontally() const;
127 
129  void setPrintScientific (bool value) const; // Yes, 'const'
130 
132  bool getPrintScientific () const;
133 
135 
136 protected:
137 
139  virtual void copy (const Vector& src);
140 
143 
144 #ifdef QUESO_CLASSES_INSTANTIATE_NEW_MAPS
145 
147  const Map m_map;
148 #else
149 
151  const Map& m_map;
152 #endif
153 
155  mutable bool m_printHorizontally;
156 
158  mutable bool m_printScientific;
159 };
160 
161 } // End namespace QUESO
162 
163 #endif // UQ_VECTOR_H
A class for partitioning vectors and matrices.
Definition: Map.h:49
const Map & map() const
Definition: Vector.C:143
bool getPrintScientific() const
Checks if the vector should be printed in Scientific Notation.
Definition: Vector.C:177
const BaseEnvironment & env() const
Definition: Vector.C:136
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:187
Vector & operator*=(double a)
Operator for multiplication of the vector by a scalar.
Definition: Vector.C:90
Vector & operator=(const Vector &rhs)
Operator for copying a vector.
Definition: Vector.C:79
Vector()
Default Constructor.
Definition: Vector.C:32
bool m_printHorizontally
Flag for either or not print this matrix horizontally.
Definition: Vector.h:155
virtual void cwSetGaussian(double mean, double stdDev)=0
Component-wise set the values of the vector to a random number from a Gaussian distribution.
virtual void cwSet(double value)=0
Component-wise set the values of the vector to value.
Vector & operator+=(const Vector &rhs)
Operator for addition (element-wise) of two vectors.
Definition: Vector.C:114
bool getPrintHorizontally() const
Checks if vector is printed horizontally.
Definition: Vector.C:164
virtual void print(std::ostream &os) const =0
Print this vector.
void setPrintHorizontally(bool value) const
Determines whether vector should be printed horizontally.
Definition: Vector.C:157
virtual unsigned int sizeLocal() const =0
Returns the local size of the vector.
virtual void copy(const Vector &src)
Copies vector src to this matrix.
Definition: Vector.C:183
Vector & operator/=(double a)
Operator for division of the vector by a scalar.
Definition: Vector.C:102
unsigned int numOfProcsForStorage() const
Definition: Vector.C:150
virtual void sort()=0
Sort the elements.
Class for vector operations (virtual).
Definition: Vector.h:47
Vector & operator-=(const Vector &rhs)
Operator for subtraction (element-wise) of two vectors.
Definition: Vector.C:125
bool m_printScientific
Flag for either or not print this matrix in scientific notation.
Definition: Vector.h:158
virtual unsigned int sizeGlobal() const =0
Returns the global size of the vector.
virtual void cwInvert()=0
Component-wise invert the values of the vector.
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:142
virtual ~Vector()
Virtual Destructor.
Definition: Vector.C:73
void setPrintScientific(bool value) const
Determines whether vector should be printed in Scientific Notation.
Definition: Vector.C:170
const Map & m_map
Mapping variable.
Definition: Vector.h:151

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