queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
TeuchosVector.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_TEUCHOS_VECTOR_H
26 #define UQ_TEUCHOS_VECTOR_H
27 
28 #ifdef QUESO_HAS_TRILINOS
29 #include <Teuchos_SerialDenseVector.hpp>
30 #include <Teuchos_SerialDenseMatrix.hpp>
31 #include <Teuchos_LAPACK.hpp>
32 #endif
33 
34 #include <queso/Defines.h>
35 #include <queso/Vector.h>
36 #include <vector>
37 
38 #ifdef QUESO_HAS_TRILINOS
39 
40 namespace QUESO {
41 
55 class TeuchosVector : public Vector
56 {
57 public:
58 
60 
61 
63  TeuchosVector(const BaseEnvironment& env, const Map& map);
64 
66  TeuchosVector(const BaseEnvironment& env, const Map& map, double value);
67 
69  TeuchosVector(const BaseEnvironment& env, double d1, double d2, const Map& map);
70 
72  TeuchosVector(const TeuchosVector& v, double d1, double d2);
73 
75  TeuchosVector(const TeuchosVector& y);
76 
80 
81 
83 
84  TeuchosVector& operator= (double a);
86 
89 
91  TeuchosVector& operator*=(double a);
92 
94  TeuchosVector& operator/=(double a);
95 
98 
101 
104 
108 
110 
111  double& operator[](unsigned int i);
113 
115  const double& operator[](unsigned int i) const;
117 
119 
120  unsigned int sizeLocal () const;
122 
124  unsigned int sizeGlobal () const;
125 
126  //TODO
127  double* values () ;
128 
130  double getMaxValue () const;
131 
133  double getMinValue () const;
134 
136  int getMaxValueIndex () const;
137 
139  int getMinValueIndex () const;
140 
142  void getMaxValueAndIndex( double& value, int& index );
143 
145  void getMinValueAndIndex( double& value, int& index );
147 
149 
150  double norm2Sq () const;
152 
154  double norm2 () const;
155 
157  double norm1 () const;
158 
160  double normInf () const;
161 
162 
164 
165 
167 
168  bool atLeastOneComponentSmallerThan (const TeuchosVector& rhs) const;
170 
172  bool atLeastOneComponentBiggerThan (const TeuchosVector& rhs) const;
173 
176 
178  bool atLeastOneComponentBiggerOrEqualThan (const TeuchosVector& rhs) const;
180 
182 
183  void cwSet(double value);
185 
187  void cwSet(unsigned int initialPos, const TeuchosVector& vec);
188 
190  void cwExtract(unsigned int initialPos, TeuchosVector& vec) const;
191 
193  void cwInvert();
194 
196  void cwSqrt();
197 
199  void cwSetConcatenated(const TeuchosVector& v1, const TeuchosVector& v2);
200 
202  void cwSetGaussian(double mean, double stdDev);
203 
205  void cwSetGaussian(const TeuchosVector& meanVec, const TeuchosVector& stdDevVec);
206 
208  void cwSetUniform (const TeuchosVector& lowerBoundVec, const TeuchosVector& upperBoundVec);
209 
211  void cwSetBeta (const TeuchosVector& alpha, const TeuchosVector& beta );
212 
214  void cwSetGamma (const TeuchosVector& a, const TeuchosVector& b );
215 
217  void cwSetInverseGamma(const TeuchosVector& a, const TeuchosVector& b );
219 
221 
222 
224  TeuchosVector abs() const;
225 
227 
228  void copy_to_std_vector(std::vector<double>& vec); // output
229 
231 
232  void copy_from_std_vector(const std::vector<double> vec);
233 
235 
236  void sort ();
237 
239  double sumOfComponents () const;
240 
242  void mpiBcast (int srcRank, const MpiComm& bcastComm);
243 
245  void mpiAllReduce (RawType_MPI_Op mpiOperation, const MpiComm& opComm, TeuchosVector& resultVec) const;
246 
248  void mpiAllQuantile (double probability, const MpiComm& opComm, TeuchosVector& resultVec) const;
249 
251 
254  void matlabLinearInterpExtrap(const TeuchosVector& xVec, const TeuchosVector& yVec, const TeuchosVector& xiVec);
255 
256  //TODO
257  void matlabDiff (unsigned int firstPositionToStoreDiff, double valueForRemainderPosition, TeuchosVector& outputVec) const;
258 
260 
262 
263  void print (std::ostream& os) const;
265  void subReadContents (const std::string& fileName,
266  const std::string& fileType,
267  const std::set<unsigned int>& allowedSubEnvIds);
268  void subWriteContents (const std::string& varNamePrefix,
269  const std::string& fileName,
270  const std::string& fileType,
271  const std::set<unsigned int>& allowedSubEnvIds) const;
273 
274 
275 
276 
277 
278 private:
280 
281  TeuchosVector();
282 
284  Teuchos::SerialDenseVector<int,double> m_vec;
285 
287  void copy (const TeuchosVector& src);
288 
289 };
290 
291 //TeuchosVector copy (int , double []);
292 TeuchosVector operator/ (double a, const TeuchosVector& x );
294 TeuchosVector operator* (double a, const TeuchosVector& x );
296 double scalarProduct(const TeuchosVector& x, const TeuchosVector& y );
299 bool operator== (const TeuchosVector& lhs, const TeuchosVector& rhs);
300 std::ostream& operator<< (std::ostream& os, const TeuchosVector& obj);
301 
302 } // End namespace QUESO
303 
304 #endif // ifdef QUESO_HAS_TRILINOS
305 
306 #endif //UQ_TEUCHOS_VECTOR_H
void cwSetGaussian(double mean, double stdDev)
This function sets component-wise Gaussian random variates, with mean mean and standard deviation std...
TeuchosVector & operator-=(const TeuchosVector &rhs)
Stores in this vector the coordinate-wise subtraction of this and rhs.
TeuchosVector & operator/=(double a)
Stores in this vector the coordinate-wise division of this by a.
void matlabDiff(unsigned int firstPositionToStoreDiff, double valueForRemainderPosition, TeuchosVector &outputVec) const
void copy_from_std_vector(const std::vector< double > vec)
Copies the values of std::vector structure to this vector (a TeuchosVector).
void mpiAllQuantile(double probability, const MpiComm &opComm, TeuchosVector &resultVec) const
Gathers values from a group of processes and returns all quantiles.
int getMaxValueIndex() const
This function returns the index of the maximum value in the vector this.
double norm2Sq() const
Returns the norm of the vector, as the square root of 2-norm of this vector.
A class for partitioning vectors and matrices.
Definition: Map.h:49
double sumOfComponents() const
Returns the sum of the components of the vector.
void mpiAllReduce(RawType_MPI_Op mpiOperation, const MpiComm &opComm, TeuchosVector &resultVec) const
Combines values from all processes and distributes the result back to all processes.
bool atLeastOneComponentBiggerOrEqualThan(const TeuchosVector &rhs) const
This function returns true if at least one component of this is bigger than or equal to the respectiv...
unsigned int sizeLocal() const
Returns the length of this vector.
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:198
void matlabLinearInterpExtrap(const TeuchosVector &xVec, const TeuchosVector &yVec, const TeuchosVector &xiVec)
Reproduces MATLAB linear inter/extra-polation.
void cwSetBeta(const TeuchosVector &alpha, const TeuchosVector &beta)
This function sets component-wise random variates from the Beta distribution, with vector parameters ...
void getMinValueAndIndex(double &value, int &index)
This function returns minimum value in the vector this and its the index.
void cwSetUniform(const TeuchosVector &lowerBoundVec, const TeuchosVector &upperBoundVec)
This function sets component-wise a number uniformly distributed in the range of elements of [lowerBo...
std::ostream & operator<<(std::ostream &os, const SequenceStatisticalOptions &obj)
bool atLeastOneComponentSmallerOrEqualThan(const TeuchosVector &rhs) const
This function returns true if at least one component of this is smaller than or equal to the respecti...
bool atLeastOneComponentSmallerThan(const TeuchosVector &rhs) const
This function returns true if at least one component of this is smaller than the respective component...
double getMaxValue() const
Returns the maximum value in the this vector.
void cwSetConcatenated(const TeuchosVector &v1, const TeuchosVector &v2)
This function concatenates vectors v1 and v2 into this vector.
GslMatrix operator-(const GslMatrix &m1, const GslMatrix &m2)
Definition: GslMatrix.C:2029
double & operator[](unsigned int i)
Element access method (non-const).
double getMinValue() const
Returns the minimum value in the this vector.
void cwSqrt()
Component-wise sets the square-root of this.
TeuchosVector()
Default Constructor.
double scalarProduct(const GslVector &x, const GslVector &y)
Definition: GslVector.C:1137
bool operator==(const GslVector &lhs, const GslVector &rhs)
Definition: GslVector.C:1168
TeuchosVector abs() const
This function returns absolute value of all elements in this.
Class for vector operations (virtual).
Definition: Vector.h:47
TeuchosVector & operator*=(double a)
Stores in this vector the coordinate-wise multiplication of this and a.
void sort()
This function sorts the elements of the vector this in ascending numerical order. ...
unsigned int sizeGlobal() const
Returns the global length of this vector.
Teuchos::SerialDenseVector< int, double > m_vec
Teuchos vector.
void cwInvert()
This function inverts component-wise the element values of this.
void cwSetGamma(const TeuchosVector &a, const TeuchosVector &b)
This function sets component-wise random variates from the Inverse Gamma distribution, with parameters given by vectors a and b.
GslMatrix operator*(double a, const GslMatrix &mat)
Definition: GslMatrix.C:1982
void subReadContents(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds)
void copy(const TeuchosVector &src)
This function copies the elements of the vector src into this.
~TeuchosVector()
Destructor.
Class for vector operations using Teuchos (Trilinos).
Definition: TeuchosVector.h:55
const BaseEnvironment & env() const
Definition: Vector.C:54
void subWriteContents(const std::string &varNamePrefix, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
TeuchosVector & operator+=(const TeuchosVector &rhs)
Stores in this vector the coordinate-wise addition of this and rhs.
TeuchosVector & operator=(double a)
Set all values in the vector to a constant value.
const Map & map() const
Definition: Vector.C:61
GslVector operator/(double a, const GslVector &x)
Definition: GslVector.C:1104
void cwSet(double value)
Component-wise sets all values to this with value.
MPI_Op RawType_MPI_Op
Definition: MpiComm.h:45
double norm2() const
Returns the 2-norm (Euclidean norm) of the vector.
void cwExtract(unsigned int initialPos, TeuchosVector &vec) const
Component-wise extracts all values of this with vector vec, starting at position initialPos.
int getMinValueIndex() const
This function returns the index of the minimum value in the vector this.
The QUESO MPI Communicator Class.
Definition: MpiComm.h:203
void cwSetInverseGamma(const TeuchosVector &a, const TeuchosVector &b)
This function sets component-wise random variates from the Inverse Gamma distribution, with parameters given by vectors a and b.
void getMaxValueAndIndex(double &value, int &index)
This function returns maximum value in the vector this and its the index.
void mpiBcast(int srcRank, const MpiComm &bcastComm)
Broadcasts a message from the process with srcRank root to all other processes of the group...
void copy_to_std_vector(std::vector< double > &vec)
Copies the values of this vector (a TeuchosVector) to a std::vector structure.
double norm1() const
Returns the 1-norm of the vector.
bool atLeastOneComponentBiggerThan(const TeuchosVector &rhs) const
This function returns true if at least one component of this is bigger than the respective component ...
double normInf() const
Returns the infinity-norm (maximum norm) of the vector.
GslMatrix operator+(const GslMatrix &m1, const GslMatrix &m2)
Definition: GslMatrix.C:2022
void print(std::ostream &os) const
Print method. Defines the behavior of the std::ostream &lt;&lt; operator inherited from the Object class...

Generated on Tue Jun 5 2018 19:48:54 for queso-0.57.1 by  doxygen 1.8.5