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

This class allows the representation of a transition kernel with a scaled covariance matrix. More...

#include <ScaledCovMatrixTKGroup.h>

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

Public Member Functions

Constructor/Destructor methods
 ScaledCovMatrixTKGroup (const char *prefix, const VectorSpace< V, M > &vectorSpace, const std::vector< double > &scales, const M &covMatrix)
 Default constructor. More...
 
 ~ScaledCovMatrixTKGroup ()
 Destructor. More...
 
Statistical/Mathematical methods
bool symmetric () const
 Whether or not the matrix is symmetric. Always 'true'. More...
 
const GaussianVectorRV< V, M > & rv (unsigned int stageId) const
 Gaussian increment property to construct a transition kernel. More...
 
const GaussianVectorRV< V, M > & rv (const std::vector< unsigned int > &stageIds)
 Gaussian increment property to construct a transition kernel. More...
 
void updateLawCovMatrix (const M &covMatrix)
 Scales the covariance matrix. More...
 
Misc methods
bool setPreComputingPosition (const V &position, unsigned int stageId)
 Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position. More...
 
void clearPreComputingPositions ()
 Clears the pre-computing positions m_preComputingPositions[stageId]. More...
 
I/O methods
void print (std::ostream &os) const
 TODO: Prints the transition kernel. More...
 
- Public Member Functions inherited from QUESO::BaseTKGroup< V, M >
 BaseTKGroup ()
 Default constructor. More...
 
 BaseTKGroup (const char *prefix, const VectorSpace< V, M > &vectorSpace, const std::vector< double > &scales)
 Constructor. More...
 
virtual ~BaseTKGroup ()
 Destructor. More...
 
const BaseEnvironmentenv () const
 QUESO's environment. More...
 
const V & preComputingPosition (unsigned int stageId) const
 Pre-computing position; access to protected attribute *m_preComputingPositions[stageId]. More...
 

Private Member Functions

void setRVsWithZeroMean ()
 Sets the mean of the RVs to zero. More...
 

Private Attributes

m_originalCovMatrix
 

Additional Inherited Members

- Protected Attributes inherited from QUESO::BaseTKGroup< V, M >
const EmptyEnvironmentm_emptyEnv
 
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSpace< V, M > * m_vectorSpace
 
std::vector< double > m_scales
 
std::vector< const V * > m_preComputingPositions
 
std::vector< BaseVectorRV< V,
M > * > 
m_rvs
 

Detailed Description

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

This class allows the representation of a transition kernel with a scaled covariance matrix.

Definition at line 44 of file ScaledCovMatrixTKGroup.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::ScaledCovMatrixTKGroup< V, M >::ScaledCovMatrixTKGroup ( const char *  prefix,
const VectorSpace< V, M > &  vectorSpace,
const std::vector< double > &  scales,
const M &  covMatrix 
)

Default constructor.

Definition at line 34 of file ScaledCovMatrixTKGroup.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseTKGroup< V, M >::m_env, QUESO::ScaledCovMatrixTKGroup< V, M >::m_originalCovMatrix, QUESO::BaseTKGroup< V, M >::m_preComputingPositions, QUESO::BaseTKGroup< V, M >::m_rvs, QUESO::BaseTKGroup< V, M >::m_scales, QUESO::ScaledCovMatrixTKGroup< V, M >::setRVsWithZeroMean(), and QUESO::BaseEnvironment::subDisplayFile().

39  :
40  BaseTKGroup<V,M>(prefix,vectorSpace,scales),
41  m_originalCovMatrix (covMatrix)
42 {
43  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
44  *m_env.subDisplayFile() << "Entering ScaledCovMatrixTKGroup<V,M>::constructor()"
45  << std::endl;
46  }
47 
48  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
49  *m_env.subDisplayFile() << "In ScaledCovMatrixTKGroup<V,M>::constructor()"
50  << ": m_scales.size() = " << m_scales.size()
51  << ", m_preComputingPositions.size() = " << m_preComputingPositions.size()
52  << ", m_rvs.size() = " << m_rvs.size()
53  << ", m_originalCovMatrix = " << m_originalCovMatrix
54  << std::endl;
55  }
56 
58 
59  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
60  *m_env.subDisplayFile() << "Leaving ScaledCovMatrixTKGroup<V,M>::constructor()"
61  << std::endl;
62  }
63 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
const BaseEnvironment & m_env
Definition: TKGroup.h:100
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:104
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
std::vector< double > m_scales
Definition: TKGroup.h:103
void setRVsWithZeroMean()
Sets the mean of the RVs to zero.
template<class V , class M >
QUESO::ScaledCovMatrixTKGroup< V, M >::~ScaledCovMatrixTKGroup ( )

Destructor.

Definition at line 66 of file ScaledCovMatrixTKGroup.C.

67 {
68 }

Member Function Documentation

template<class V , class M >
void QUESO::ScaledCovMatrixTKGroup< V, M >::clearPreComputingPositions ( )
virtual

Clears the pre-computing positions m_preComputingPositions[stageId].

Reimplemented from QUESO::BaseTKGroup< V, M >.

Definition at line 199 of file ScaledCovMatrixTKGroup.C.

References QUESO::BaseTKGroup< V, M >::clearPreComputingPositions().

200 {
202  return;
203 }
virtual void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId].
Definition: TKGroup.C:109
template<class V , class M >
void QUESO::ScaledCovMatrixTKGroup< V, M >::print ( std::ostream &  os) const
virtual

TODO: Prints the transition kernel.

Todo:
: implement me!

Reimplemented from QUESO::BaseTKGroup< V, M >.

Definition at line 229 of file ScaledCovMatrixTKGroup.C.

References QUESO::BaseTKGroup< V, M >::print().

230 {
232  return;
233 }
virtual void print(std::ostream &os) const
TODO: Prints the transition kernel.
Definition: TKGroup.C:123
template<class V , class M >
const GaussianVectorRV< V, M > & QUESO::ScaledCovMatrixTKGroup< V, M >::rv ( unsigned int  stageId) const
virtual

Gaussian increment property to construct a transition kernel.

Implements QUESO::BaseTKGroup< V, M >.

Definition at line 79 of file ScaledCovMatrixTKGroup.C.

References queso_require_greater_msg, queso_require_msg, queso_require_not_equal_to_msg, and QUESO::GaussianVectorRV< V, M >::updateLawExpVector().

80 {
81  queso_require_not_equal_to_msg(m_rvs.size(), 0, "m_rvs.size() = 0");
82 
83  queso_require_msg(m_rvs[0], "m_rvs[0] == NULL");
84 
85  queso_require_greater_msg(m_preComputingPositions.size(), stageId, "m_preComputingPositions.size() <= stageId");
86 
87  queso_require_msg(m_preComputingPositions[stageId], "m_preComputingPositions[stageId] == NULL");
88 
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] // FIX ME: might demand parallelism
95  << std::endl;
96  }
97 
98  GaussianVectorRV<V, M> * gaussian_rv = dynamic_cast<GaussianVectorRV<V, M> * >(m_rvs[0]);
99 
100  gaussian_rv->updateLawExpVector(*m_preComputingPositions[stageId]);
101 
102  return (*gaussian_rv);
103 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:86
const BaseEnvironment & m_env
Definition: TKGroup.h:100
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:104
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
#define queso_require_greater_msg(expr1, expr2, msg)
Definition: asserts.h:88
template<class V , class M >
const GaussianVectorRV< V, M > & QUESO::ScaledCovMatrixTKGroup< V, M >::rv ( const std::vector< unsigned int > &  stageIds)
virtual

Gaussian increment property to construct a transition kernel.

Implements QUESO::BaseTKGroup< V, M >.

Definition at line 107 of file ScaledCovMatrixTKGroup.C.

References queso_require_greater_equal_msg, queso_require_greater_msg, queso_require_msg, and QUESO::GaussianVectorRV< V, M >::updateLawExpVector().

108 {
109  queso_require_greater_equal_msg(m_rvs.size(), stageIds.size(), "m_rvs.size() < stageIds.size()");
110 
111  queso_require_msg(m_rvs[stageIds.size()-1], "m_rvs[stageIds.size()-1] == NULL");
112 
113  queso_require_greater_msg(m_preComputingPositions.size(), stageIds[0], "m_preComputingPositions.size() <= stageIds[0]");
114 
115  queso_require_msg(m_preComputingPositions[stageIds[0]], "m_preComputingPositions[stageIds[0]] == NULL");
116 
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]] // FIX ME: might demand parallelism
124  << std::endl;
125  }
126 
127  GaussianVectorRV<V, M> * gaussian_rv = dynamic_cast<GaussianVectorRV<V, M> * >(m_rvs[stageIds.size()-1]);
128 
129  gaussian_rv->updateLawExpVector(*m_preComputingPositions[stageIds[0]]);
130 
131  return (*gaussian_rv);
132 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
const BaseEnvironment & m_env
Definition: TKGroup.h:100
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:104
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
#define queso_require_greater_equal_msg(expr1, expr2, msg)
Definition: asserts.h:90
#define queso_require_greater_msg(expr1, expr2, msg)
Definition: asserts.h:88
template<class V , class M >
bool QUESO::ScaledCovMatrixTKGroup< V, M >::setPreComputingPosition ( const V &  position,
unsigned int  stageId 
)
virtual

Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position.

Reimplemented from QUESO::BaseTKGroup< V, M >.

Definition at line 160 of file ScaledCovMatrixTKGroup.C.

References QUESO::GaussianJointPdf< V, M >::lawCovMatrix(), and QUESO::BaseTKGroup< V, M >::setPreComputingPosition().

161 {
162  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
163  *m_env.subDisplayFile() << "Entering ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
164  << ": position = " << position
165  << ", stageId = " << stageId
166  << std::endl;
167  }
168 
170  //setRVsWithZeroMean();
171 
172  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
173  *m_env.subDisplayFile() << "In ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
174  << ", position = " << position
175  << ", stageId = " << stageId
176  << ": preComputingPos = " << *m_preComputingPositions[stageId];
177  if (stageId < m_scales.size()) {
178  *m_env.subDisplayFile() << ", factor = " << 1./m_scales[stageId]/m_scales[stageId];
179  }
180  if (stageId < m_rvs.size()) {
181  const GaussianJointPdf<V,M>* pdfPtr = dynamic_cast< const GaussianJointPdf<V,M>* >(&(m_rvs[stageId]->pdf()));
182  *m_env.subDisplayFile() << ", rvCov = " << pdfPtr->lawCovMatrix(); // FIX ME: might demand parallelism
183  }
184  *m_env.subDisplayFile() << std::endl;
185  }
186 
187  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
188  *m_env.subDisplayFile() << "Leaving ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
189  << ": position = " << position
190  << ", stageId = " << stageId
191  << std::endl;
192  }
193 
194  return true;
195 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
virtual bool setPreComputingPosition(const V &position, unsigned int stageId)
Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position...
Definition: TKGroup.C:96
const BaseEnvironment & m_env
Definition: TKGroup.h:100
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:104
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
std::vector< double > m_scales
Definition: TKGroup.h:103
template<class V , class M >
void QUESO::ScaledCovMatrixTKGroup< V, M >::setRVsWithZeroMean ( )
private

Sets the mean of the RVs to zero.

Definition at line 209 of file ScaledCovMatrixTKGroup.C.

References queso_require_equal_to_msg, queso_require_msg, and queso_require_not_equal_to_msg.

Referenced by QUESO::ScaledCovMatrixTKGroup< V, M >::ScaledCovMatrixTKGroup().

210 {
211  queso_require_not_equal_to_msg(m_rvs.size(), 0, "m_rvs.size() = 0");
212 
213  queso_require_equal_to_msg(m_rvs.size(), m_scales.size(), "m_rvs.size() != m_scales.size()");
214 
215  for (unsigned int i = 0; i < m_scales.size(); ++i) {
216  double factor = 1./m_scales[i]/m_scales[i];
217  queso_require_msg(!(m_rvs[i]), "m_rvs[i] != NULL");
218  m_rvs[i] = new GaussianVectorRV<V,M>(m_prefix.c_str(),
219  *m_vectorSpace,
220  m_vectorSpace->zeroVector(),
221  factor*m_originalCovMatrix);
222  }
223 
224  return;
225 }
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:86
const VectorSpace< V, M > * m_vectorSpace
Definition: TKGroup.h:102
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
std::vector< double > m_scales
Definition: TKGroup.h:103
std::string m_prefix
Definition: TKGroup.h:101
template<class V , class M >
bool QUESO::ScaledCovMatrixTKGroup< V, M >::symmetric ( ) const
virtual

Whether or not the matrix is symmetric. Always 'true'.

Todo:
: It only returns 'true', thus a test for its symmetricity must be included.

Implements QUESO::BaseTKGroup< V, M >.

Definition at line 72 of file ScaledCovMatrixTKGroup.C.

73 {
74  return true;
75 }
template<class V , class M >
void QUESO::ScaledCovMatrixTKGroup< V, M >::updateLawCovMatrix ( const M &  covMatrix)

Scales the covariance matrix.

The covariance matrix is scaled by a factor of $ 1/scales^2 $.

Definition at line 136 of file ScaledCovMatrixTKGroup.C.

137 {
138  for (unsigned int i = 0; i < m_scales.size(); ++i) {
139  double factor = 1./m_scales[i]/m_scales[i];
140  if ((m_env.subDisplayFile() ) &&
141  (m_env.displayVerbosity() >= 10)) {
142  *m_env.subDisplayFile() << "In ScaledCovMatrixTKGroup<V,M>::updateLawCovMatrix()"
143  << ", m_scales.size() = " << m_scales.size()
144  << ", i = " << i
145  << ", m_scales[i] = " << m_scales[i]
146  << ", factor = " << factor
147  << ": about to call m_rvs[i]->updateLawCovMatrix()"
148  << ", covMatrix = \n" << factor*covMatrix // FIX ME: might demand parallelism
149  << std::endl;
150  }
151  dynamic_cast<GaussianVectorRV<V, M> * >(m_rvs[i])->updateLawCovMatrix(factor*covMatrix);
152  }
153 
154  return;
155 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
void updateLawCovMatrix(const M &covMatrix)
Scales the covariance matrix.
const BaseEnvironment & m_env
Definition: TKGroup.h:100
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
std::vector< double > m_scales
Definition: TKGroup.h:103

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
M QUESO::ScaledCovMatrixTKGroup< V, M >::m_originalCovMatrix
private

The documentation for this class was generated from the following files:

Generated on Thu Jun 11 2015 13:52:36 for queso-0.53.0 by  doxygen 1.8.5