queso-0.53.0
GenericMatrixCovarianceFunction.C
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 #include <queso/GenericMatrixCovarianceFunction.h>
26 
27 namespace QUESO {
28 
29 // Default constructor -----------------------------
30 
31 template<class P_V, class P_M, class Q_V, class Q_M>
33  const char* prefix,
34  const VectorSet<P_V,P_M>& basicDomainSet,
35  const VectorSet<Q_V,Q_M>& imageSet,
36  void (*covRoutinePtr)(const P_V& positionVector1, const P_V& positionVector2, const void* routineDataPtr, Q_M& imageMatrix),
37  const void* routinesDataPtr)
38  :
39  BaseMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>(prefix,basicDomainSet,imageSet),
40  m_covRoutinePtr (covRoutinePtr),
41  m_routineDataPtr (routinesDataPtr)
42 {
43  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
44  *m_env.subDisplayFile() << "Entering GenericMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::constructor()"
45  << ": prefix = " << m_prefix
46  << std::endl;
47  }
48 
49  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
50  *m_env.subDisplayFile() << "Leaving GenericMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::constructor()"
51  << ": prefix = " << m_prefix
52  << std::endl;
53  }
54 }
55 // Destructor ---------------------------------------
56 template<class P_V, class P_M, class Q_V, class Q_M>
58 {
59  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
60  *m_env.subDisplayFile() << "Entering GenericMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::destructor()"
61  << ": prefix = " << m_prefix
62  << std::endl;
63  }
64 
65  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
66  *m_env.subDisplayFile() << "Leaving GenericMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::destructor()"
67  << ": prefix = " << m_prefix
68  << std::endl;
69  }
70 }
71 // Math methods -------------------------------------
72 template<class P_V, class P_M, class Q_V, class Q_M>
73 void
74 GenericMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix(const P_V& positionVector1, const P_V& positionVector2, Q_M& imageMatrix) const
75 {
76  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
77  *m_env.subDisplayFile() << "Entering GenericMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()"
78  << std::endl;
79  }
80 
81  unsigned int matrixOrder = m_imageSet.vectorSpace().dimLocal();
82 
83  queso_require_equal_to_msg(imageMatrix.numRowsLocal(), matrixOrder, "imageMatrix has invalid number of rows");
84 
85  queso_require_equal_to_msg(imageMatrix.numCols(), matrixOrder, "imageMatrix has invalid number of columns");
86 
87  queso_require_msg(m_covRoutinePtr, "m_covRoutinePtr = NULL");
88 
89  m_covRoutinePtr(positionVector1, positionVector2, m_routineDataPtr, imageMatrix);
90 
91  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
92  *m_env.subDisplayFile() << "Leaving GenericMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()"
93  << std::endl;
94  }
95 
96  return;
97 }
98 
99 } // End namespace QUESO
void covMatrix(const P_V &positionVector1, const P_V &positionVector2, Q_M &imageMatrix) const
Calculates the value of the generic covariance matrix.
unsigned int displayVerbosity() const
Definition: Environment.C:396
GenericMatrixCovarianceFunction(const char *prefix, const VectorSet< P_V, P_M > &basicDomainSet, const VectorSet< Q_V, Q_M > &imageSet, void(*covRoutinePtr)(const P_V &positionVector1, const P_V &positionVector2, const void *routineDataPtr, Q_M &imageMatrix), const void *routinesDataPtr)
Default constructor.
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
virtual ~GenericMatrixCovarianceFunction()
Virtual destructor.
A templated (base) class to accommodate covariance matrix of (random) vector functions.

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