queso-0.51.1
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,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_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 
64  TeuchosVector();
65 
67  TeuchosVector(const BaseEnvironment& env, const Map& map);
68 
70  TeuchosVector(const BaseEnvironment& env, const Map& map, double value);
71 
73  TeuchosVector(const BaseEnvironment& env, double d1, double d2, const Map& map);
74 
76  TeuchosVector(const TeuchosVector& v, double d1, double d2);
77 
79  TeuchosVector(const TeuchosVector& y);
80 
82  ~TeuchosVector();
84 
85 
87 
88  TeuchosVector& operator= (double a);
90 
92  TeuchosVector& operator= (const TeuchosVector& rhs);
93 
95  TeuchosVector& operator*=(double a);
96 
98  TeuchosVector& operator/=(double a);
99 
101  TeuchosVector& operator*=(const TeuchosVector& rhs);
102 
104  TeuchosVector& operator/=(const TeuchosVector& rhs);
105 
107  TeuchosVector& operator+=(const TeuchosVector& rhs);
108 
110  TeuchosVector& operator-=(const TeuchosVector& rhs);
112 
114 
115  double& operator[](unsigned int i);
117 
119  const double& operator[](unsigned int i) const;
121 
123 
124  unsigned int sizeLocal () const;
126 
128  unsigned int sizeGlobal () const;
129 
130  //TODO
131  double* values () ;
132 
134  double getMaxValue () const;
135 
137  double getMinValue () const;
138 
140  int getMaxValueIndex () const;
141 
143  int getMinValueIndex () const;
144 
146  void getMaxValueAndIndex( double& value, int& index );
147 
149  void getMinValueAndIndex( double& value, int& index );
151 
153 
154  double norm2Sq () const;
156 
158  double norm2 () const;
159 
161  double norm1 () const;
162 
164  double normInf () const;
165 
166 
168 
169 
171 
172  bool atLeastOneComponentSmallerThan (const TeuchosVector& rhs) const;
174 
176  bool atLeastOneComponentBiggerThan (const TeuchosVector& rhs) const;
177 
179  bool atLeastOneComponentSmallerOrEqualThan(const TeuchosVector& rhs) const;
180 
182  bool atLeastOneComponentBiggerOrEqualThan (const TeuchosVector& rhs) const;
184 
186 
187  void cwSet(double value);
189 
191  void cwSet(unsigned int initialPos, const TeuchosVector& vec);
192 
194  void cwExtract(unsigned int initialPos, TeuchosVector& vec) const;
195 
197  void cwInvert();
198 
200  void cwSqrt();
201 
203  void cwSetConcatenated(const TeuchosVector& v1, const TeuchosVector& v2);
204 
206  void cwSetGaussian(double mean, double stdDev);
207 
209  void cwSetGaussian(const TeuchosVector& meanVec, const TeuchosVector& stdDevVec);
210 
212  void cwSetUniform (const TeuchosVector& lowerBoundVec, const TeuchosVector& upperBoundVec);
213 
215  void cwSetBeta (const TeuchosVector& alpha, const TeuchosVector& beta );
216 
218  void cwSetGamma (const TeuchosVector& a, const TeuchosVector& b );
219 
221  void cwSetInverseGamma(const TeuchosVector& a, const TeuchosVector& b );
223 
225 
226 
228  TeuchosVector abs() const;
229 
231 
232  void copy_to_std_vector(std::vector<double>& vec); // output
233 
235 
236  void copy_from_std_vector(const std::vector<double> vec);
237 
239 
240  void sort ();
241 
243  double sumOfComponents () const;
244 
246  void mpiBcast (int srcRank, const MpiComm& bcastComm);
247 
249  void mpiAllReduce (RawType_MPI_Op mpiOperation, const MpiComm& opComm, TeuchosVector& resultVec) const;
250 
252  void mpiAllQuantile (double probability, const MpiComm& opComm, TeuchosVector& resultVec) const;
253 
255 
258  void matlabLinearInterpExtrap(const TeuchosVector& xVec, const TeuchosVector& yVec, const TeuchosVector& xiVec);
259 
260  //TODO
261  void matlabDiff (unsigned int firstPositionToStoreDiff, double valueForRemainderPosition, TeuchosVector& outputVec) const;
262 
264 
266 
267  void print (std::ostream& os) const;
269  void subReadContents (const std::string& fileName,
270  const std::string& fileType,
271  const std::set<unsigned int>& allowedSubEnvIds);
272  void subWriteContents (const std::string& varNamePrefix,
273  const std::string& fileName,
274  const std::string& fileType,
275  const std::set<unsigned int>& allowedSubEnvIds) const;
277 
278 
279 
280 
281 
282 private:
283 
285  Teuchos::SerialDenseVector<int,double> m_vec;
286 
288  void copy (const TeuchosVector& src);
289 
290 };
291 
292 //TeuchosVector copy (int , double []);
293 TeuchosVector operator/ (double a, const TeuchosVector& x );
294 TeuchosVector operator/ (const TeuchosVector& x, const TeuchosVector& y );
295 TeuchosVector operator* (double a, const TeuchosVector& x );
296 TeuchosVector operator* (const TeuchosVector& x, const TeuchosVector& y );
297 double scalarProduct(const TeuchosVector& x, const TeuchosVector& y );
298 TeuchosVector operator+ (const TeuchosVector& x, const TeuchosVector& y );
299 TeuchosVector operator- (const TeuchosVector& x, const TeuchosVector& y );
300 bool operator== (const TeuchosVector& lhs, const TeuchosVector& rhs);
301 std::ostream& operator<< (std::ostream& os, const TeuchosVector& obj);
302 
303 } // End namespace QUESO
304 
305 #endif // ifdef QUESO_HAS_TRILINOS
306 
307 #endif //UQ_TEUCHOS_VECTOR_H
GslMatrix operator+(const GslMatrix &m1, const GslMatrix &m2)
Definition: GslMatrix.C:2395
GslMatrix operator-(const GslMatrix &m1, const GslMatrix &m2)
Definition: GslMatrix.C:2402
double scalarProduct(const GslVector &x, const GslVector &y)
Definition: GslVector.C:1360
std::ostream & operator<<(std::ostream &os, const BaseEnvironment &obj)
bool operator==(const GslVector &lhs, const GslVector &rhs)
Definition: GslVector.C:1394
GslVector operator/(double a, const GslVector &x)
Definition: GslVector.C:1327
GslMatrix operator*(double a, const GslMatrix &mat)
Definition: GslMatrix.C:2352
MPI_Op RawType_MPI_Op
Definition: MpiComm.h:41

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