queso-0.53.0
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-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_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 
78  ~TeuchosVector();
80 
81 
83 
84  TeuchosVector& operator= (double a);
86 
88  TeuchosVector& operator= (const TeuchosVector& rhs);
89 
91  TeuchosVector& operator*=(double a);
92 
94  TeuchosVector& operator/=(double a);
95 
97  TeuchosVector& operator*=(const TeuchosVector& rhs);
98 
100  TeuchosVector& operator/=(const TeuchosVector& rhs);
101 
103  TeuchosVector& operator+=(const TeuchosVector& rhs);
104 
106  TeuchosVector& operator-=(const TeuchosVector& rhs);
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 
175  bool atLeastOneComponentSmallerOrEqualThan(const TeuchosVector& rhs) const;
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 );
293 TeuchosVector operator/ (const TeuchosVector& x, const TeuchosVector& y );
294 TeuchosVector operator* (double a, const TeuchosVector& x );
295 TeuchosVector operator* (const TeuchosVector& x, const TeuchosVector& y );
296 double scalarProduct(const TeuchosVector& x, const TeuchosVector& y );
297 TeuchosVector operator+ (const TeuchosVector& x, const TeuchosVector& y );
298 TeuchosVector operator- (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
GslMatrix operator*(double a, const GslMatrix &mat)
Definition: GslMatrix.C:1972
MPI_Op RawType_MPI_Op
Definition: MpiComm.h:41
std::ostream & operator<<(std::ostream &os, const BaseEnvironment &obj)
GslVector operator/(double a, const GslVector &x)
Definition: GslVector.C:1117
GslMatrix operator+(const GslMatrix &m1, const GslMatrix &m2)
Definition: GslMatrix.C:2012
double scalarProduct(const GslVector &x, const GslVector &y)
Definition: GslVector.C:1150
GslMatrix operator-(const GslMatrix &m1, const GslMatrix &m2)
Definition: GslMatrix.C:2019
bool operator==(const GslVector &lhs, const GslVector &rhs)
Definition: GslVector.C:1181
and that you are informed that you can do these things To protect your we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it For if you distribute copies of the whether gratis or for a you must give the recipients all the rights that we gave you You must make sure that receive or can get the source code If you link other code with the you must provide complete object files to the so that they can relink them with the library after making changes to the library and recompiling it And you must show them these terms so they know their rights We protect your rights with a two step which gives you legal permission to copy
Definition: License.txt:60

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