queso-0.50.1
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)
 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< GaussianVectorRV
< V, M > * > 
m_rvs
 

Detailed Description

template<class V, class M>
class QUESO::ScaledCovMatrixTKGroup< V, M >

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

Definition at line 41 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 33 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().

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

Destructor.

Definition at line 65 of file ScaledCovMatrixTKGroup.C.

66 {
67 }

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 216 of file ScaledCovMatrixTKGroup.C.

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

217 {
219  return;
220 }
virtual void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId].
Definition: TKGroup.C:121
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 255 of file ScaledCovMatrixTKGroup.C.

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

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

Gaussian increment property to construct a transition kernel.

Implements QUESO::BaseTKGroup< V, M >.

Definition at line 78 of file ScaledCovMatrixTKGroup.C.

References UQ_FATAL_TEST_MACRO.

79 {
80  UQ_FATAL_TEST_MACRO(m_rvs.size() == 0,
81  m_env.worldRank(),
82  "ScaledCovMatrixTKGroup<V,M>::rv1()",
83  "m_rvs.size() = 0");
84 
85  UQ_FATAL_TEST_MACRO(m_rvs[0] == NULL, // Yes, '0', because that is the id used below
86  m_env.worldRank(),
87  "ScaledCovMatrixTKGroup<V,M>::rv1()",
88  "m_rvs[0] == NULL");
89 
91  m_env.worldRank(),
92  "ScaledCovMatrixTKGroup<V,M>::rv1()",
93  "m_preComputingPositions.size() <= stageId");
94 
96  m_env.worldRank(),
97  "ScaledCovMatrixTKGroup<V,M>::rv1()",
98  "m_preComputingPositions[stageId] == NULL");
99 
100  if ((m_env.subDisplayFile() ) &&
101  (m_env.displayVerbosity() >= 10)) {
102  *m_env.subDisplayFile() << "In ScaledCovMatrixTKGroup<V,M>::rv1()"
103  << ", stageId = " << stageId
104  << ": about to call m_rvs[0]->updateLawExpVector()"
105  << ", vector = " << *m_preComputingPositions[stageId] // FIX ME: might demand parallelism
106  << std::endl;
107  }
108  m_rvs[0]->updateLawExpVector(*m_preComputingPositions[stageId]);
109 
110  return (*m_rvs[0]);
111 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:102
std::vector< GaussianVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:103
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
unsigned int displayVerbosity() const
Definition: Environment.C:436
const BaseEnvironment & m_env
Definition: TKGroup.h:98
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 115 of file ScaledCovMatrixTKGroup.C.

References UQ_FATAL_TEST_MACRO.

116 {
117  UQ_FATAL_TEST_MACRO(m_rvs.size() < stageIds.size(),
118  m_env.worldRank(),
119  "ScaledCovMatrixTKGroup<V,M>::rv2()",
120  "m_rvs.size() < stageIds.size()");
121 
122  UQ_FATAL_TEST_MACRO(m_rvs[stageIds.size()-1] == NULL,
123  m_env.worldRank(),
124  "ScaledCovMatrixTKGroup<V,M>::rv2()",
125  "m_rvs[stageIds.size()-1] == NULL");
126 
127  UQ_FATAL_TEST_MACRO(m_preComputingPositions.size() <= stageIds[0],
128  m_env.worldRank(),
129  "ScaledCovMatrixTKGroup<V,M>::rv2()",
130  "m_preComputingPositions.size() <= stageIds[0]");
131 
132  UQ_FATAL_TEST_MACRO(m_preComputingPositions[stageIds[0]] == NULL,
133  m_env.worldRank(),
134  "ScaledCovMatrixTKGroup<V,M>::rv2()",
135  "m_preComputingPositions[stageIds[0]] == NULL");
136 
137  if ((m_env.subDisplayFile() ) &&
138  (m_env.displayVerbosity() >= 10)) {
139  *m_env.subDisplayFile() << "In ScaledCovMatrixTKGroup<V,M>::rv2()"
140  << ", stageIds.size() = " << stageIds.size()
141  << ", stageIds[0] = " << stageIds[0]
142  << ": about to call m_rvs[stageIds.size()-1]->updateLawExpVector()"
143  << ", vector = " << *m_preComputingPositions[stageIds[0]] // FIX ME: might demand parallelism
144  << std::endl;
145  }
146  m_rvs[stageIds.size()-1]->updateLawExpVector(*m_preComputingPositions[stageIds[0]]);
147 
148  return (*m_rvs[stageIds.size()-1]);
149 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:102
std::vector< GaussianVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:103
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
unsigned int displayVerbosity() const
Definition: Environment.C:436
const BaseEnvironment & m_env
Definition: TKGroup.h:98
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 177 of file ScaledCovMatrixTKGroup.C.

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

178 {
179  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
180  *m_env.subDisplayFile() << "Entering ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
181  << ": position = " << position
182  << ", stageId = " << stageId
183  << std::endl;
184  }
185 
187  //setRVsWithZeroMean();
188 
189  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
190  *m_env.subDisplayFile() << "In ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
191  << ", position = " << position
192  << ", stageId = " << stageId
193  << ": preComputingPos = " << *m_preComputingPositions[stageId];
194  if (stageId < m_scales.size()) {
195  *m_env.subDisplayFile() << ", factor = " << 1./m_scales[stageId]/m_scales[stageId];
196  }
197  if (stageId < m_rvs.size()) {
198  const GaussianJointPdf<V,M>* pdfPtr = dynamic_cast< const GaussianJointPdf<V,M>* >(&(m_rvs[stageId]->pdf()));
199  *m_env.subDisplayFile() << ", rvCov = " << pdfPtr->lawCovMatrix(); // FIX ME: might demand parallelism
200  }
201  *m_env.subDisplayFile() << std::endl;
202  }
203 
204  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
205  *m_env.subDisplayFile() << "Leaving ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
206  << ": position = " << position
207  << ", stageId = " << stageId
208  << std::endl;
209  }
210 
211  return true;
212 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:102
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:102
std::vector< GaussianVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:103
unsigned int displayVerbosity() const
Definition: Environment.C:436
std::vector< double > m_scales
Definition: TKGroup.h:101
const BaseEnvironment & m_env
Definition: TKGroup.h:98
template<class V , class M >
void QUESO::ScaledCovMatrixTKGroup< V, M >::setRVsWithZeroMean ( )
private

Sets the mean of the RVs to zero.

Definition at line 226 of file ScaledCovMatrixTKGroup.C.

References UQ_FATAL_TEST_MACRO.

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

227 {
228  UQ_FATAL_TEST_MACRO(m_rvs.size() == 0,
229  m_env.worldRank(),
230  "ScaledCovMatrixTKGroup<V,M>::setRVsWithZeroMean()",
231  "m_rvs.size() = 0");
232 
233  UQ_FATAL_TEST_MACRO(m_rvs.size() != m_scales.size(),
234  m_env.worldRank(),
235  "ScaledCovMatrixTKGroup<V,M>::setRVsWithZeroMean()",
236  "m_rvs.size() != m_scales.size()");
237 
238  for (unsigned int i = 0; i < m_scales.size(); ++i) {
239  double factor = 1./m_scales[i]/m_scales[i];
240  UQ_FATAL_TEST_MACRO(m_rvs[i] != NULL,
241  m_env.worldRank(),
242  "ScaledCovMatrixTKGroup<V,M>::setRVsWithZeroMean()",
243  "m_rvs[i] != NULL");
244  m_rvs[i] = new GaussianVectorRV<V,M>(m_prefix.c_str(),
245  *m_vectorSpace,
246  m_vectorSpace->zeroVector(),
247  factor*m_originalCovMatrix);
248  }
249 
250  return;
251 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::vector< GaussianVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:103
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
const VectorSpace< V, M > * m_vectorSpace
Definition: TKGroup.h:100
std::vector< double > m_scales
Definition: TKGroup.h:101
std::string m_prefix
Definition: TKGroup.h:99
const BaseEnvironment & m_env
Definition: TKGroup.h:98
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 71 of file ScaledCovMatrixTKGroup.C.

72 {
73  return true;
74 }
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 153 of file ScaledCovMatrixTKGroup.C.

Referenced by QUESO::MetropolisHastingsSG< P_V, P_M >::generateFullChain().

154 {
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()
161  << ", i = " << i
162  << ", m_scales[i] = " << m_scales[i]
163  << ", factor = " << factor
164  << ": about to call m_rvs[i]->updateLawCovMatrix()"
165  << ", covMatrix = \n" << factor*covMatrix // FIX ME: might demand parallelism
166  << std::endl;
167  }
168  m_rvs[i]->updateLawCovMatrix(factor*covMatrix);
169  }
170 
171  return;
172 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
std::vector< GaussianVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:103
unsigned int displayVerbosity() const
Definition: Environment.C:436
std::vector< double > m_scales
Definition: TKGroup.h:101
const BaseEnvironment & m_env
Definition: TKGroup.h:98

Member Data Documentation

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

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

Generated on Thu Apr 23 2015 19:18:37 for queso-0.50.1 by  doxygen 1.8.5