queso-0.53.0
Public Member Functions | Private Attributes | List of all members
QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M > Class Template Reference

A class representing a Gaussian likelihood with block-diagonal covariance matrix. More...

#include <GaussianLikelihoodBlockDiagonalCovariance.h>

Inheritance diagram for QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >:
Inheritance graph
[legend]
Collaboration diagram for QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >:
Collaboration graph
[legend]

Public Member Functions

double & blockCoefficient (unsigned int i)
 Get (non-const) multiplicative coefficient for block i. More...
 
const double & getBlockCoefficient (unsigned int i) const
 Get (const) multiplicative coefficient for block i. More...
 
virtual double actualValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Actual value of the scalar function. More...
 
virtual double lnValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Logarithm of the value of the scalar function. More...
 
Constructor/Destructor methods.
 GaussianLikelihoodBlockDiagonalCovariance (const char *prefix, const VectorSet< V, M > &domainSet, const V &observations, const GslBlockMatrix &covariance)
 Default constructor. More...
 
virtual ~GaussianLikelihoodBlockDiagonalCovariance ()
 Destructor. More...
 
- Public Member Functions inherited from QUESO::BaseGaussianLikelihood< V, M >
virtual void evaluateModel (const V &domainVector, const V *domainDirection, V &modelOutput, V *gradVector, M *hessianMatrix, V *hessianEffect) const =0
 Evaluates the user's model at the point domainVector. More...
 
 BaseGaussianLikelihood (const char *prefix, const VectorSet< V, M > &domainSet, const V &observations)
 Default constructor. More...
 
virtual ~BaseGaussianLikelihood ()
 Destructor. More...
 
- Public Member Functions inherited from QUESO::BaseScalarFunction< V, M >
 BaseScalarFunction (const char *prefix, const VectorSet< V, M > &domainSet)
 Default constructor. More...
 
virtual ~BaseScalarFunction ()
 Destructor. More...
 
const VectorSet< V, M > & domainSet () const
 Access to the protected attribute m_domainSet: domain set of the scalar function. More...
 

Private Attributes

std::vector< double > m_covarianceCoefficients
 
const GslBlockMatrixm_covariance
 

Additional Inherited Members

- Protected Attributes inherited from QUESO::BaseGaussianLikelihood< V, M >
const V & m_observations
 
- Protected Attributes inherited from QUESO::BaseScalarFunction< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSet< V, M > & m_domainSet
 Domain set of the scalar function. More...
 

Detailed Description

template<class V = GslVector, class M = GslMatrix>
class QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >

A class representing a Gaussian likelihood with block-diagonal covariance matrix.

Definition at line 45 of file GaussianLikelihoodBlockDiagonalCovariance.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >::GaussianLikelihoodBlockDiagonalCovariance ( const char *  prefix,
const VectorSet< V, M > &  domainSet,
const V &  observations,
const GslBlockMatrix covariance 
)

Default constructor.

Instantiates a Gaussian likelihood function, given a prefix, its domain, a vector of observations and a block diagonal covariance matrix. The diagonal covariance matrix is of type GslBlockMatrix. Each block in the block diagonal matrix is an object of type GslMatrix.

Furthermore, each block comes with a multiplicative coefficient which defaults to 1.0.

Definition at line 35 of file GaussianLikelihoodBlockDiagonalCovariance.C.

References QUESO::GslBlockMatrix::getBlock(), QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >::m_covariance, QUESO::GslBlockMatrix::numBlocks(), QUESO::GslMatrix::numRowsLocal(), and queso_error_msg.

38  : BaseGaussianLikelihood<V, M>(prefix, domainSet, observations),
39  m_covarianceCoefficients(covariance.numBlocks(), 1.0),
40  m_covariance(covariance)
41 {
42  unsigned int totalDim = 0;
43 
44  for (unsigned int i = 0; i < this->m_covariance.numBlocks(); i++) {
45  totalDim += this->m_covariance.getBlock(i).numRowsLocal();
46  }
47 
48  if (totalDim != observations.sizeLocal()) {
49  queso_error_msg("Covariance matrix not same dimension as observation vector");
50  }
51 }
#define queso_error_msg(msg)
Definition: asserts.h:47
GslMatrix & getBlock(unsigned int i) const
Return block i in the block diagonal matrix.
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
Definition: GslMatrix.C:300
const VectorSet< V, M > & domainSet() const
Access to the protected attribute m_domainSet: domain set of the scalar function. ...
unsigned int numBlocks() const
Return the number of blocks in the block diagonal matrix.

Destructor.

Definition at line 54 of file GaussianLikelihoodBlockDiagonalCovariance.C.

55 {
56 }

Member Function Documentation

template<class V , class M >
double QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >::actualValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
virtual

Actual value of the scalar function.

Implements QUESO::BaseScalarFunction< V, M >.

Definition at line 76 of file GaussianLikelihoodBlockDiagonalCovariance.C.

79 {
80  return std::exp(this->lnValue(domainVector, domainDirection, gradVector,
81  hessianMatrix, hessianEffect));
82 }
virtual double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Logarithm of the value of the scalar function.
template<class V , class M >
double & QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >::blockCoefficient ( unsigned int  i)

Get (non-const) multiplicative coefficient for block i.

Definition at line 60 of file GaussianLikelihoodBlockDiagonalCovariance.C.

template<class V , class M >
const double & QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >::getBlockCoefficient ( unsigned int  i) const

Get (const) multiplicative coefficient for block i.

Definition at line 68 of file GaussianLikelihoodBlockDiagonalCovariance.C.

template<class V , class M >
double QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >::lnValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
virtual

Logarithm of the value of the scalar function.

Implements QUESO::BaseScalarFunction< V, M >.

Definition at line 86 of file GaussianLikelihoodBlockDiagonalCovariance.C.

89 {
90  V modelOutput(this->m_observations, 0, 0); // At least it's not a copy
91  V weightedMisfit(this->m_observations, 0, 0); // At least it's not a copy
92 
93  this->evaluateModel(domainVector, domainDirection, modelOutput, gradVector,
94  hessianMatrix, hessianEffect);
95 
96  // Compute misfit G(x) - y
97  modelOutput -= this->m_observations;
98 
99  // Solve \Sigma u = G(x) - y for u
100  this->m_covariance.invertMultiply(modelOutput, weightedMisfit);
101 
102  // Deal with the multiplicative coefficients for each of the blocks
103  unsigned int offset = 0;
104 
105  // For each block...
106  for (unsigned int i = 0; i < this->m_covariance.numBlocks(); i++) {
107  // ...divide the appropriate parts of the solution by the coefficient
108  unsigned int blockDim = this->m_covariance.getBlock(i).numRowsLocal();
109  for (unsigned int j = 0; j < blockDim; j++) {
110  // coefficient is a variance, so we divide by it
111  modelOutput[offset+j] /= this->m_covarianceCoefficients[i];
112  }
113  offset += blockDim;
114  }
115 
116  // Compute (G(x) - y)^T \Sigma^{-1} (G(x) - y)
117  modelOutput *= weightedMisfit;
118 
119  double norm2_squared = modelOutput.sumOfComponents(); // This is square of 2-norm
120 
121  return -0.5 * norm2_squared;
122 }
virtual void evaluateModel(const V &domainVector, const V *domainDirection, V &modelOutput, V *gradVector, M *hessianMatrix, V *hessianEffect) const =0
Evaluates the user&#39;s model at the point domainVector.
GslMatrix & getBlock(unsigned int i) const
Return block i in the block diagonal matrix.
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
Definition: GslMatrix.C:300
void invertMultiply(const GslVector &b, GslVector &x) const
This function calculates the inverse of this matrix, multiplies it with vector b and stores the resul...
unsigned int numBlocks() const
Return the number of blocks in the block diagonal matrix.

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
const GslBlockMatrix& QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >::m_covariance
private
template<class V = GslVector, class M = GslMatrix>
std::vector<double> QUESO::GaussianLikelihoodBlockDiagonalCovariance< V, M >::m_covarianceCoefficients
private

Definition at line 82 of file GaussianLikelihoodBlockDiagonalCovariance.h.


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