27 #include <queso/GslVector.h>
28 #include <queso/GslMatrix.h>
29 #include <queso/VectorSet.h>
30 #include <queso/GaussianLikelihoodFullCovariance.h>
34 template<
class V,
class M>
37 const V & observations,
const M & covariance,
double covarianceCoefficient)
39 m_covarianceCoefficient(covarianceCoefficient),
40 m_covariance(covariance)
42 if (covariance.numRowsLocal() != observations.sizeLocal()) {
43 queso_error_msg(
"Covariance matrix not same size as observation vector");
47 template<
class V,
class M>
52 template<
class V,
class M>
56 V modelOutput(this->m_observations, 0, 0);
57 V weightedMisfit(this->m_observations, 0, 0);
59 this->evaluateModel(domainVector, modelOutput);
62 modelOutput -= this->m_observations;
65 this->m_covariance.invertMultiply(modelOutput, weightedMisfit);
68 modelOutput *= weightedMisfit;
71 double norm2_squared = modelOutput.sumOfComponents();
73 return -0.5 * norm2_squared / (this->m_covarianceCoefficient);
GaussianLikelihoodFullCovariance(const char *prefix, const VectorSet< V, M > &domainSet, const V &observations, const M &covariance, double covarianceCoefficient=1.0)
Default constructor.
A templated class for handling sets.
A class that represents a Gaussian likelihood with full covariance.
virtual ~GaussianLikelihoodFullCovariance()
Destructor.
virtual double lnValue(const V &domainVector) const
Logarithm of the value of the scalar function.
Base class for canned Gaussian likelihoods.