25 #include <queso/ScaledCovMatrixTKGroup.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
28 #include <queso/GaussianJointPdf.h>
33 template<
class V,
class M>
37 const std::vector<double>& scales,
41 m_originalCovMatrix (covMatrix)
50 <<
": m_scales.size() = " <<
m_scales.size()
52 <<
", m_rvs.size() = " <<
m_rvs.size()
65 template<
class V,
class M>
70 template<
class V,
class M>
77 template<
class V,
class M>
83 queso_require_msg(m_rvs[0],
"m_rvs[0] == NULL");
85 queso_require_greater_msg(m_preComputingPositions.size(), stageId,
"m_preComputingPositions.size() <= stageId");
87 queso_require_msg(m_preComputingPositions[stageId],
"m_preComputingPositions[stageId] == NULL");
89 if ((m_env.subDisplayFile() ) &&
90 (m_env.displayVerbosity() >= 10)) {
91 *m_env.subDisplayFile() <<
"In ScaledCovMatrixTKGroup<V,M>::rv1()"
92 <<
", stageId = " << stageId
93 <<
": about to call m_rvs[0]->updateLawExpVector()"
94 <<
", vector = " << *m_preComputingPositions[stageId]
102 return (*gaussian_rv);
105 template<
class V,
class M>
109 queso_require_greater_equal_msg(m_rvs.size(), stageIds.size(),
"m_rvs.size() < stageIds.size()");
111 queso_require_msg(m_rvs[stageIds.size()-1],
"m_rvs[stageIds.size()-1] == NULL");
113 queso_require_greater_msg(m_preComputingPositions.size(), stageIds[0],
"m_preComputingPositions.size() <= stageIds[0]");
115 queso_require_msg(m_preComputingPositions[stageIds[0]],
"m_preComputingPositions[stageIds[0]] == NULL");
117 if ((m_env.subDisplayFile() ) &&
118 (m_env.displayVerbosity() >= 10)) {
119 *m_env.subDisplayFile() <<
"In ScaledCovMatrixTKGroup<V,M>::rv2()"
120 <<
", stageIds.size() = " << stageIds.size()
121 <<
", stageIds[0] = " << stageIds[0]
122 <<
": about to call m_rvs[stageIds.size()-1]->updateLawExpVector()"
123 <<
", vector = " << *m_preComputingPositions[stageIds[0]]
131 return (*gaussian_rv);
134 template <
class V,
class M>
139 queso_require_msg(m_rvs[0],
"m_rvs[0] == NULL");
147 return (*gaussian_rv);
151 template<
class V,
class M>
155 for (
unsigned int i = 0; i < m_scales.size(); ++i) {
156 double factor = 1./m_scales[i]/m_scales[i];
157 if ((m_env.subDisplayFile() ) &&
158 (m_env.displayVerbosity() >= 10)) {
159 *m_env.subDisplayFile() <<
"In ScaledCovMatrixTKGroup<V,M>::updateLawCovMatrix()"
160 <<
", m_scales.size() = " << m_scales.size()
162 <<
", m_scales[i] = " << m_scales[i]
163 <<
", factor = " << factor
164 <<
": about to call m_rvs[i]->updateLawCovMatrix()"
165 <<
", covMatrix = \n" << factor*covMatrix
173 template<
class V,
class M>
177 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
178 *m_env.subDisplayFile() <<
"Entering ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
179 <<
": position = " << position
180 <<
", stageId = " << stageId
187 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
188 *m_env.subDisplayFile() <<
"In ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
189 <<
", position = " << position
190 <<
", stageId = " << stageId
191 <<
": preComputingPos = " << *m_preComputingPositions[stageId];
192 if (stageId < m_scales.size()) {
193 *m_env.subDisplayFile() <<
", factor = " << 1./m_scales[stageId]/m_scales[stageId];
195 if (stageId < m_rvs.size()) {
197 *m_env.subDisplayFile() <<
", rvCov = " << pdfPtr->
lawCovMatrix();
199 *m_env.subDisplayFile() << std::endl;
202 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
203 *m_env.subDisplayFile() <<
"Leaving ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
204 <<
": position = " << position
205 <<
", stageId = " << stageId
212 template<
class V,
class M>
219 template <
class V,
class M>
223 unsigned int old_stageId = this->m_stageId;
224 this->m_stageId = stageId;
229 template<
class V,
class M>
237 for (
unsigned int i = 0; i < m_scales.size(); ++i) {
238 double factor = 1./m_scales[i]/m_scales[i];
239 queso_require_msg(!(m_rvs[i]),
"m_rvs[i] != NULL");
242 m_vectorSpace->zeroVector(),
243 factor*m_originalCovMatrix);
247 template<
class V,
class M>
A class for handling Gaussian joint PDFs.
std::vector< const V * > m_preComputingPositions
A class representing a vector space.
A class representing a Gaussian vector RV.
virtual unsigned int set_dr_stage(unsigned int stageId)
Sets the internal m_stageId varialbe to stageId.
std::vector< BaseVectorRV< V, M > * > m_rvs
const BaseEnvironment & m_env
virtual void print(std::ostream &os) const
TODO: Prints the transition kernel.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix queso_require_not_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the absence of an options input file"))
virtual void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId].
void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId].
const GaussianVectorRV< V, M > & rv(unsigned int stageId) const
Gaussian increment property to construct a transition kernel.
bool symmetric() const
Whether or not the matrix is symmetric. Always 'true'.
void updateLawExpVector(const V &newLawExpVector)
Updates the vector that contains the mean values.
std::vector< double > m_scales
const M & lawCovMatrix() const
Returns the covariance matrix; access to protected attribute m_lawCovMatrix.
This base class allows the representation of a transition kernel.
bool setPreComputingPosition(const V &position, unsigned int stageId)
Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position...
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
ScaledCovMatrixTKGroup(const char *prefix, const VectorSpace< V, M > &vectorSpace, const std::vector< double > &scales, const M &covMatrix)
Default constructor.
void setRVsWithZeroMean()
Sets the mean of the RVs to zero.
unsigned int displayVerbosity() const
virtual bool setPreComputingPosition(const V &position, unsigned int stageId)
Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position...
void print(std::ostream &os) const
TODO: Prints the transition kernel.
This class allows the representation of a transition kernel with a scaled covariance matrix...
~ScaledCovMatrixTKGroup()
Destructor.
void updateLawCovMatrix(const M &covMatrix)
Scales the covariance matrix.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).