queso-0.53.0
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 = GslVector, class P_M = GslMatrix, class Q_V = GslVector, class Q_M = GslMatrix>
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 50 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_require_equal_to_msg, QUESO::BaseEnvironment::subDisplayFile(), and QUESO::VectorSet< V, M >::vectorSpace().

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  queso_require_equal_to_msg(m_sigmas->numRowsLocal(), matrixOrder, "m_sigmas has invalid number of rows");
54 
55  queso_require_equal_to_msg(m_sigmas->numCols(), matrixOrder, "m_sigmas has invalid number of columns");
56 
57  queso_require_equal_to_msg(m_as->numRowsLocal(), matrixOrder, "m_as has invalid number of rows");
58 
59  queso_require_equal_to_msg(m_as->numCols(), matrixOrder, "m_as has invalid number of columns");
60 
61  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
62  *m_env.subDisplayFile() << "Leaving ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::constructor()"
63  << ": prefix = " << m_prefix
64  << std::endl;
65  }
66 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
const VectorSet< Q_V, Q_M > & m_imageSet
unsigned int dimLocal() const
Definition: VectorSpace.C:170
const VectorSet< P_V, P_M > & basicDomainSet() const
Domain set; access to private attribute m_basicDomainSet.
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
virtual const VectorSpace< V, M > & vectorSpace() const =0
Vector space to which this set belongs to. See template specialization.
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 69 of file ExponentialMatrixCovarianceFunction.C.

70 {
71  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
72  *m_env.subDisplayFile() << "Entering ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::destructor()"
73  << ": prefix = " << m_prefix
74  << std::endl;
75  }
76 
77  delete m_as;
78  delete m_sigmas;
79 
80  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
81  *m_env.subDisplayFile() << "Leaving ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::destructor()"
82  << ": prefix = " << m_prefix
83  << std::endl;
84  }
85 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274

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 89 of file ExponentialMatrixCovarianceFunction.C.

References queso_require_equal_to_msg.

90 {
91  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
92  *m_env.subDisplayFile() << "Entering ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()"
93  << std::endl;
94  }
95 
96  unsigned int matrixOrder = m_imageSet.vectorSpace().dimLocal();
97 
98  queso_require_equal_to_msg(imageMatrix.numRowsLocal(), matrixOrder, "imageMatrix has invalid number of rows");
99 
100  queso_require_equal_to_msg(imageMatrix.numCols(), matrixOrder, "imageMatrix has invalid number of columns");
101 
102  double tmpSq = -(domainVector1 - domainVector2).norm2Sq();
103 
104  for (unsigned int i = 0; i < matrixOrder; ++i) {
105  for (unsigned int j = 0; j < matrixOrder; ++j) {
106  double tmp = tmpSq/( (*m_sigmas)(i,j) * (*m_sigmas)(i,j) );
107  imageMatrix(i,j) = (*m_as)(i,j) * std::exp(tmp);
108  }
109  }
110 
111  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
112  *m_env.subDisplayFile() << "Leaving ExponentialMatrixCovarianceFunction<P_V,P_M,Q_V,Q_M>::covMatrix()"
113  << std::endl;
114  }
115 
116  return;
117 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
const VectorSet< Q_V, Q_M > & m_imageSet
unsigned int dimLocal() const
Definition: VectorSpace.C:170
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
virtual const VectorSpace< V, M > & vectorSpace() const =0
Vector space to which this set belongs to. See template specialization.

Member Data Documentation

template<class P_V = GslVector, class P_M = GslMatrix, class Q_V = GslVector, class Q_M = GslMatrix>
Q_M* QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::m_as
protected
template<class P_V = GslVector, class P_M = GslMatrix, class Q_V = GslVector, class Q_M = GslMatrix>
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 Jun 11 2015 13:52:35 for queso-0.53.0 by  doxygen 1.8.5