25 #include <queso/GslVector.h>
26 #include <queso/GslMatrix.h>
27 #include <queso/VectorSet.h>
28 #include <queso/VectorSpace.h>
29 #include <queso/GaussianLikelihoodFullCovarianceRandomCoefficient.h>
33 template<
class V,
class M>
36 const V & observations,
const M & covariance)
38 m_covariance(covariance)
40 if (covariance.numRowsLocal() != observations.sizeLocal()) {
41 queso_error_msg(
"Covariance matrix not same size as observation vector");
45 template<
class V,
class M>
50 template<
class V,
class M>
53 const V & domainVector,
const V * domainDirection, V * gradVector,
54 M * hessianMatrix, V * hessianEffect)
const
56 return std::exp(this->lnValue(domainVector, domainDirection, gradVector,
57 hessianMatrix, hessianEffect));
60 template<
class V,
class M>
63 const V & domainVector,
const V * domainDirection, V * gradVector,
64 M * hessianMatrix, V * hessianEffect)
const
66 V modelOutput(this->m_observations, 0, 0);
67 V weightedMisfit(this->m_observations, 0, 0);
69 this->evaluateModel(domainVector, domainDirection, modelOutput, gradVector,
70 hessianMatrix, hessianEffect);
73 modelOutput -= this->m_observations;
76 this->m_covariance.invertMultiply(modelOutput, weightedMisfit);
79 modelOutput *= weightedMisfit;
82 double norm2_squared = modelOutput.sumOfComponents();
86 return -0.5 * norm2_squared / (domainVector[domainVector.sizeLocal()-1]);
A templated class for handling sets.
virtual double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Logarithm of the value of the scalar function.
#define queso_error_msg(msg)
A class that represents a Gaussian likelihood with full covariance and random coefficient.
virtual ~GaussianLikelihoodFullCovarianceRandomCoefficient()
Destructor.
virtual double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Actual value of the scalar function.
Base class for canned Gaussian likelihoods.
GaussianLikelihoodFullCovarianceRandomCoefficient(const char *prefix, const VectorSet< V, M > &domainSet, const V &observations, const M &covariance)
Default constructor.