queso-0.51.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) 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, 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 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 }
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:104
std::vector< double > m_scales
Definition: TKGroup.h:102
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const BaseEnvironment & m_env
Definition: TKGroup.h:99
unsigned int displayVerbosity() const
Definition: Environment.C:436
std::vector< const V * > m_preComputingPositions
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 223 of file ScaledCovMatrixTKGroup.C.

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

224 {
226  return;
227 }
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 262 of file ScaledCovMatrixTKGroup.C.

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

263 {
265  return;
266 }
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) 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::GaussianVectorRV< V, M >::updateLawExpVector(), and UQ_FATAL_TEST_MACRO.

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

References QUESO::GaussianVectorRV< V, M >::updateLawExpVector(), and UQ_FATAL_TEST_MACRO.

120 {
121  UQ_FATAL_TEST_MACRO(m_rvs.size() < stageIds.size(),
122  m_env.worldRank(),
123  "ScaledCovMatrixTKGroup<V,M>::rv2()",
124  "m_rvs.size() < stageIds.size()");
125 
126  UQ_FATAL_TEST_MACRO(m_rvs[stageIds.size()-1] == NULL,
127  m_env.worldRank(),
128  "ScaledCovMatrixTKGroup<V,M>::rv2()",
129  "m_rvs[stageIds.size()-1] == NULL");
130 
131  UQ_FATAL_TEST_MACRO(m_preComputingPositions.size() <= stageIds[0],
132  m_env.worldRank(),
133  "ScaledCovMatrixTKGroup<V,M>::rv2()",
134  "m_preComputingPositions.size() <= stageIds[0]");
135 
136  UQ_FATAL_TEST_MACRO(m_preComputingPositions[stageIds[0]] == NULL,
137  m_env.worldRank(),
138  "ScaledCovMatrixTKGroup<V,M>::rv2()",
139  "m_preComputingPositions[stageIds[0]] == NULL");
140 
141  if ((m_env.subDisplayFile() ) &&
142  (m_env.displayVerbosity() >= 10)) {
143  *m_env.subDisplayFile() << "In ScaledCovMatrixTKGroup<V,M>::rv2()"
144  << ", stageIds.size() = " << stageIds.size()
145  << ", stageIds[0] = " << stageIds[0]
146  << ": about to call m_rvs[stageIds.size()-1]->updateLawExpVector()"
147  << ", vector = " << *m_preComputingPositions[stageIds[0]] // FIX ME: might demand parallelism
148  << std::endl;
149  }
150 
151  GaussianVectorRV<V, M> * gaussian_rv = dynamic_cast<GaussianVectorRV<V, M> * >(m_rvs[stageIds.size()-1]);
152 
153  gaussian_rv->updateLawExpVector(*m_preComputingPositions[stageIds[0]]);
154 
155  return (*gaussian_rv);
156 }
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:104
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
const BaseEnvironment & m_env
Definition: TKGroup.h:99
unsigned int displayVerbosity() const
Definition: Environment.C:436
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:103
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 184 of file ScaledCovMatrixTKGroup.C.

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

185 {
186  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
187  *m_env.subDisplayFile() << "Entering ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
188  << ": position = " << position
189  << ", stageId = " << stageId
190  << std::endl;
191  }
192 
194  //setRVsWithZeroMean();
195 
196  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
197  *m_env.subDisplayFile() << "In ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
198  << ", position = " << position
199  << ", stageId = " << stageId
200  << ": preComputingPos = " << *m_preComputingPositions[stageId];
201  if (stageId < m_scales.size()) {
202  *m_env.subDisplayFile() << ", factor = " << 1./m_scales[stageId]/m_scales[stageId];
203  }
204  if (stageId < m_rvs.size()) {
205  const GaussianJointPdf<V,M>* pdfPtr = dynamic_cast< const GaussianJointPdf<V,M>* >(&(m_rvs[stageId]->pdf()));
206  *m_env.subDisplayFile() << ", rvCov = " << pdfPtr->lawCovMatrix(); // FIX ME: might demand parallelism
207  }
208  *m_env.subDisplayFile() << std::endl;
209  }
210 
211  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
212  *m_env.subDisplayFile() << "Leaving ScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
213  << ": position = " << position
214  << ", stageId = " << stageId
215  << std::endl;
216  }
217 
218  return true;
219 }
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:104
std::vector< double > m_scales
Definition: TKGroup.h:102
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const BaseEnvironment & m_env
Definition: TKGroup.h:99
unsigned int displayVerbosity() const
Definition: Environment.C:436
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< const V * > m_preComputingPositions
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 233 of file ScaledCovMatrixTKGroup.C.

References UQ_FATAL_TEST_MACRO.

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

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

161 {
162  for (unsigned int i = 0; i < m_scales.size(); ++i) {
163  double factor = 1./m_scales[i]/m_scales[i];
164  if ((m_env.subDisplayFile() ) &&
165  (m_env.displayVerbosity() >= 10)) {
166  *m_env.subDisplayFile() << "In ScaledCovMatrixTKGroup<V,M>::updateLawCovMatrix()"
167  << ", m_scales.size() = " << m_scales.size()
168  << ", i = " << i
169  << ", m_scales[i] = " << m_scales[i]
170  << ", factor = " << factor
171  << ": about to call m_rvs[i]->updateLawCovMatrix()"
172  << ", covMatrix = \n" << factor*covMatrix // FIX ME: might demand parallelism
173  << std::endl;
174  }
175  dynamic_cast<GaussianVectorRV<V, M> * >(m_rvs[i])->updateLawCovMatrix(factor*covMatrix);
176  }
177 
178  return;
179 }
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:104
std::vector< double > m_scales
Definition: TKGroup.h:102
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const BaseEnvironment & m_env
Definition: TKGroup.h:99
void updateLawCovMatrix(const M &covMatrix)
Scales the covariance matrix.
unsigned int displayVerbosity() const
Definition: Environment.C:436

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:26:18 for queso-0.51.1 by  doxygen 1.8.5