queso-0.51.1
Protected Attributes | List of all members
QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M > Class Template Reference

A class for exponential covariance matrices. More...

#include <ExponentialMatrixCovarianceFunction.h>

Inheritance diagram for QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >:
Inheritance graph
[legend]
Collaboration diagram for QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 ExponentialMatrixCovarianceFunction (const char *prefix, const VectorSet< P_V, P_M > &basicDomainSet, const VectorSet< Q_V, Q_M > &imageSet, const Q_M &sigmas, const Q_M &as)
 Default constructor. More...
 
virtual ~ExponentialMatrixCovarianceFunction ()
 Virtual destructor. More...
 
Math methods

@

void covMatrix (const P_V &domainVector1, const P_V &domainVector2, Q_M &imageMatrix) const
 Calculates the covariance matrix, given two parameter domains. More...
 
- Public Member Functions inherited from QUESO::BaseMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >
 BaseMatrixCovarianceFunction (const char *prefix, const VectorSet< P_V, P_M > &basicDomainSet, const VectorSet< Q_V, Q_M > &imageSet)
 Default constructor. More...
 
virtual ~BaseMatrixCovarianceFunction ()
 Virtual destructor. More...
 
const VectorSet< P_V, P_M > & basicDomainSet () const
 Domain set; access to private attribute m_basicDomainSet. More...
 

Protected Attributes

Q_M * m_sigmas
 
Q_M * m_as
 
- Protected Attributes inherited from QUESO::BaseMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSet< P_V, P_M > & m_basicDomainSet
 
const VectorSet< Q_V, Q_M > & m_imageSet
 

Detailed Description

template<class P_V, class P_M, class Q_V, class Q_M>
class QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >

A class for exponential covariance matrices.

This class implements squared exponential covariance matrices of the form:

\[ cov = a \exp{(-d^2/\sigma^2)}\]

, where $ d=d(x,y) $ is the distance between two vectors, $ \sigma^2 $ is the variance matrix and $ a $ is the length scale ().

Definition at line 47 of file ExponentialMatrixCovarianceFunction.h.

Constructor & Destructor Documentation

template<class P_V , class P_M , class Q_V , class Q_M >
QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::ExponentialMatrixCovarianceFunction ( const char *  prefix,
const VectorSet< P_V, P_M > &  basicDomainSet,
const VectorSet< Q_V, Q_M > &  imageSet,
const Q_M &  sigmas,
const Q_M &  as 
)

Default constructor.

Instantiates an object of the class given a prefix, the domain and image sets, the variances scale factors.

Definition at line 31 of file ExponentialMatrixCovarianceFunction.C.

References QUESO::VectorSpace< V, M >::dimLocal(), QUESO::BaseEnvironment::displayVerbosity(), QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::m_as, QUESO::BaseMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::m_env, QUESO::BaseMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::m_imageSet, QUESO::BaseMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::m_prefix, QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::m_sigmas, QUESO::BaseEnvironment::subDisplayFile(), UQ_FATAL_TEST_MACRO, QUESO::VectorSet< V, M >::vectorSpace(), and QUESO::BaseEnvironment::worldRank().

37  :
38  BaseMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>(prefix,basicDomainSet,imageSet),
39  m_sigmas(NULL),
40  m_as (NULL)
41 {
42  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
43  *m_env.subDisplayFile() << "Entering ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::constructor()"
44  << ": prefix = " << m_prefix
45  << std::endl;
46  }
47 
48  m_sigmas = new Q_M(sigmas);
49  m_as = new Q_M(as);
50 
51  unsigned int matrixOrder = m_imageSet.vectorSpace().dimLocal();
52 
53  UQ_FATAL_TEST_MACRO(m_sigmas->numRowsLocal() != matrixOrder,
54  m_env.worldRank(),
55  "ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::Constructor()",
56  "m_sigmas has invalid number of rows");
57 
58  UQ_FATAL_TEST_MACRO(m_sigmas->numCols() != matrixOrder,
59  m_env.worldRank(),
60  "ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::Constructor()",
61  "m_sigmas has invalid number of columns");
62 
63  UQ_FATAL_TEST_MACRO(m_as->numRowsLocal() != matrixOrder,
64  m_env.worldRank(),
65  "ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::Constructor()",
66  "m_as has invalid number of rows");
67 
68  UQ_FATAL_TEST_MACRO(m_as->numCols() != matrixOrder,
69  m_env.worldRank(),
70  "ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::Constructor()",
71  "m_as has invalid number of columns");
72 
73  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
74  *m_env.subDisplayFile() << "Leaving ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::constructor()"
75  << ": prefix = " << m_prefix
76  << std::endl;
77  }
78 }
unsigned int dimLocal() const
Definition: VectorSpace.C:199
const VectorSet< Q_V, Q_M > & m_imageSet
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const VectorSet< P_V, P_M > & basicDomainSet() const
Domain set; access to private attribute m_basicDomainSet.
unsigned int displayVerbosity() const
Definition: Environment.C:436
virtual const VectorSpace< V, M > & vectorSpace() const =0
Vector space to which this set belongs to. See template specialization.
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
template<class P_V , class P_M , class Q_V , class Q_M >
QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::~ExponentialMatrixCovarianceFunction ( )
virtual

Virtual destructor.

Definition at line 81 of file ExponentialMatrixCovarianceFunction.C.

82 {
83  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
84  *m_env.subDisplayFile() << "Entering ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::destructor()"
85  << ": prefix = " << m_prefix
86  << std::endl;
87  }
88 
89  delete m_as;
90  delete m_sigmas;
91 
92  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
93  *m_env.subDisplayFile() << "Leaving ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::destructor()"
94  << ": prefix = " << m_prefix
95  << std::endl;
96  }
97 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
unsigned int displayVerbosity() const
Definition: Environment.C:436

Member Function Documentation

template<class P_V , class P_M , class Q_V , class Q_M >
void QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::covMatrix ( const P_V &  domainVector1,
const P_V &  domainVector2,
Q_M &  imageMatrix 
) const
virtual

Calculates the covariance matrix, given two parameter domains.

Implements QUESO::BaseMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >.

Definition at line 101 of file ExponentialMatrixCovarianceFunction.C.

References UQ_FATAL_TEST_MACRO.

102 {
103  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
104  *m_env.subDisplayFile() << "Entering ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()"
105  << std::endl;
106  }
107 
108  unsigned int matrixOrder = m_imageSet.vectorSpace().dimLocal();
109 
110  UQ_FATAL_TEST_MACRO(imageMatrix.numRowsLocal() != matrixOrder,
111  m_env.worldRank(),
112  "ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()",
113  "imageMatrix has invalid number of rows");
114 
115  UQ_FATAL_TEST_MACRO(imageMatrix.numCols() != matrixOrder,
116  m_env.worldRank(),
117  "ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()",
118  "imageMatrix has invalid number of columns");
119 
120  double tmpSq = -(domainVector1 - domainVector2).norm2Sq();
121 
122  for (unsigned int i = 0; i < matrixOrder; ++i) {
123  for (unsigned int j = 0; j < matrixOrder; ++j) {
124  double tmp = tmpSq/( (*m_sigmas)(i,j) * (*m_sigmas)(i,j) );
125  imageMatrix(i,j) = (*m_as)(i,j) * std::exp(tmp);
126  }
127  }
128 
129  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
130  *m_env.subDisplayFile() << "Leaving ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()"
131  << std::endl;
132  }
133 
134  return;
135 }
unsigned int dimLocal() const
Definition: VectorSpace.C:199
const VectorSet< Q_V, Q_M > & m_imageSet
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
unsigned int displayVerbosity() const
Definition: Environment.C:436
virtual const VectorSpace< V, M > & vectorSpace() const =0
Vector space to which this set belongs to. See template specialization.
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223

Member Data Documentation

template<class P_V , class P_M , class Q_V , class Q_M >
Q_M* QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::m_as
protected
template<class P_V , class P_M , class Q_V , class Q_M >
Q_M* QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::m_sigmas
protected

The documentation for this class was generated from the following files:

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