queso-0.51.1
Private Attributes | List of all members
QUESO::GaussianVectorRealizer< V, M > Class Template Reference

A class for handling sampling from Gaussian probability density distributions. More...

#include <GaussianVectorRealizer.h>

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

Public Member Functions

Constructor/Destructor methods
 GaussianVectorRealizer (const char *prefix, const VectorSet< V, M > &unifiedImageSet, const V &lawExpVector, const M &lowerCholLawCovMatrix)
 Constructor. More...
 
 GaussianVectorRealizer (const char *prefix, const VectorSet< V, M > &unifiedImageSet, const V &lawExpVector, const M &matU, const V &vecSsqrt, const M &matVt)
 Constructor. More...
 
 ~GaussianVectorRealizer ()
 Destructor. More...
 
Realization-related methods
const V & unifiedLawExpVector () const
 Access to the vector of mean values and private attribute: m_unifiedLawExpVector. More...
 
const V & unifiedLawVarVector () const
 Access to the vector of variance values and private attribute: m_unifiedLawVarVector. More...
 
void realization (V &nextValues) const
 Draws a realization. More...
 
void updateLawExpVector (const V &newLawExpVector)
 Updates the mean with the new value newLawExpVector. More...
 
void updateLowerCholLawCovMatrix (const M &newLowerCholLawCovMatrix)
 Updates the lower triangular matrix from Cholesky decomposition of the covariance matrix to the new value newLowerCholLawCovMatrix. More...
 
void updateLowerCholLawCovMatrix (const M &matU, const V &vecSsqrt, const M &matVt)
 Updates the SVD matrices from SVD decomposition of the covariance matrix to the new values: matU, vecSsqrt, and matVt. More...
 
- Public Member Functions inherited from QUESO::BaseVectorRealizer< V, M >
 BaseVectorRealizer (const char *prefix, const VectorSet< V, M > &unifiedImageSet, unsigned int subPeriod)
 Default constructor. More...
 
virtual ~BaseVectorRealizer ()
 Virtual destructor. More...
 
const VectorSet< V, M > & unifiedImageSet () const
 Image set where the realizations lie. Access to protected attribute m_unifiedImageSet. More...
 
unsigned int subPeriod () const
 Sub-period of the realization. Access to protected attribute m_subPeriod. More...
 

Private Attributes

V * m_unifiedLawExpVector
 
V * m_unifiedLawVarVector
 
M * m_lowerCholLawCovMatrix
 
M * m_matU
 
V * m_vecSsqrt
 
M * m_matVt
 

Additional Inherited Members

- Protected Attributes inherited from QUESO::BaseVectorRealizer< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSet< V, M > & m_unifiedImageSet
 
unsigned int m_subPeriod
 

Detailed Description

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

A class for handling sampling from Gaussian probability density distributions.

This class handles sampling from a Gaussian probability density distribution.

Definition at line 45 of file GaussianVectorRealizer.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::GaussianVectorRealizer< V, M >::GaussianVectorRealizer ( const char *  prefix,
const VectorSet< V, M > &  unifiedImageSet,
const V &  lawExpVector,
const M &  lowerCholLawCovMatrix 
)

Constructor.

Constructs a new object, given a prefix and the image set of the vector realizer, a vector of mean values, lawExpVector, and a lower triangular matrix resulting from Cholesky decomposition of the covariance matrix, lowerCholLawCovMatrix.

Definition at line 33 of file GaussianVectorRealizer.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseVectorRealizer< V, M >::m_env, QUESO::BaseVectorRealizer< V, M >::m_prefix, QUESO::GaussianVectorRealizer< V, M >::m_unifiedLawExpVector, and QUESO::BaseEnvironment::subDisplayFile().

37  :
38  BaseVectorRealizer<V,M>( ((std::string)(prefix)+"gau").c_str(), unifiedImageSet, std::numeric_limits<unsigned int>::max()), // 2011/Oct/02 - Correction thanks to Corey
39  m_unifiedLawExpVector (new V(lawExpVector)),
40  m_unifiedLawVarVector (unifiedImageSet.vectorSpace().newVector( INFINITY)), // FIX ME
41  m_lowerCholLawCovMatrix(new M(lowerCholLawCovMatrix)),
42  m_matU (NULL),
43  m_vecSsqrt (NULL),
44  m_matVt (NULL)
45 {
46  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
47  *m_env.subDisplayFile() << "Entering GaussianVectorRealizer<V,M>::constructor() [1]"
48  << ": prefix = " << m_prefix
49  << std::endl;
50  }
51 
52  *m_unifiedLawExpVector = lawExpVector; // ????
53 
54  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
55  *m_env.subDisplayFile() << "Leaving GaussianVectorRealizer<V,M>::constructor() [1]"
56  << ": prefix = " << m_prefix
57  << std::endl;
58  }
59 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const BaseEnvironment & m_env
unsigned int displayVerbosity() const
Definition: Environment.C:436
const VectorSet< V, M > & unifiedImageSet() const
Image set where the realizations lie. Access to protected attribute m_unifiedImageSet.
template<class V , class M >
QUESO::GaussianVectorRealizer< V, M >::GaussianVectorRealizer ( const char *  prefix,
const VectorSet< V, M > &  unifiedImageSet,
const V &  lawExpVector,
const M &  matU,
const V &  vecSsqrt,
const M &  matVt 
)

Constructor.

Constructs a new object, given a prefix and the image set of the vector realizer, a vector of mean values, lawExpVector, and a set of two matrices and one vector resulting from the Single Value Decomposition of the covariance matrix, matU, vecSsqrt and matVt.

Definition at line 62 of file GaussianVectorRealizer.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseVectorRealizer< V, M >::m_env, QUESO::BaseVectorRealizer< V, M >::m_prefix, QUESO::GaussianVectorRealizer< V, M >::m_unifiedLawExpVector, and QUESO::BaseEnvironment::subDisplayFile().

68  :
69  BaseVectorRealizer<V,M>( ((std::string)(prefix)+"gau").c_str(), unifiedImageSet, std::numeric_limits<unsigned int>::max()), // 2011/Oct/02 - Correction thanks to Corey
70  m_unifiedLawExpVector (new V(lawExpVector)),
71  m_unifiedLawVarVector (unifiedImageSet.vectorSpace().newVector( INFINITY)), // FIX ME
73  m_matU (new M(matU)),
74  m_vecSsqrt (new V(vecSsqrt)),
75  m_matVt (new M(matVt))
76 {
77  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
78  *m_env.subDisplayFile() << "Entering GaussianVectorRealizer<V,M>::constructor() [2]"
79  << ": prefix = " << m_prefix
80  << std::endl;
81  }
82 
83  *m_unifiedLawExpVector = lawExpVector; // ????
84 
85  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
86  *m_env.subDisplayFile() << "Leaving GaussianVectorRealizer<V,M>::constructor() [2]"
87  << ": prefix = " << m_prefix
88  << std::endl;
89  }
90 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const BaseEnvironment & m_env
unsigned int displayVerbosity() const
Definition: Environment.C:436
const VectorSet< V, M > & unifiedImageSet() const
Image set where the realizations lie. Access to protected attribute m_unifiedImageSet.
template<class V , class M >
QUESO::GaussianVectorRealizer< V, M >::~GaussianVectorRealizer ( )

Member Function Documentation

template<class V , class M >
void QUESO::GaussianVectorRealizer< V, M >::realization ( V &  nextValues) const
virtual

Draws a realization.

This function draws a realization of a Gaussian distribution of mean m_unifiedLawExpVector and variance m_unifiedLawVarVector and saves it in nextValues.

Implements QUESO::BaseVectorRealizer< V, M >.

Definition at line 119 of file GaussianVectorRealizer.C.

References UQ_FATAL_TEST_MACRO.

120 {
121  V iidGaussianVector(m_unifiedImageSet.vectorSpace().zeroVector());
122 
123  bool outOfSupport = true;
124  do {
125  iidGaussianVector.cwSetGaussian(0.0, 1.0);
126 
128  nextValues = (*m_unifiedLawExpVector) + (*m_lowerCholLawCovMatrix)*iidGaussianVector;
129  }
130  else if (m_matU && m_vecSsqrt && m_matVt) {
131  nextValues = (*m_unifiedLawExpVector) + (*m_matU)*( (*m_vecSsqrt) * ((*m_matVt)*iidGaussianVector) );
132  }
133  else {
134  UQ_FATAL_TEST_MACRO(true,
135  m_env.worldRank(),
136  "GaussianVectorRealizer<V,M>::realization()",
137  "inconsistent internal state");
138  }
139 
140  outOfSupport = !(this->m_unifiedImageSet.contains(nextValues));
141  } while (outOfSupport); // prudenci 2011-Oct-04
142 
143  return;
144 }
const VectorSet< V, M > & m_unifiedImageSet
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const BaseEnvironment & m_env
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
template<class V , class M >
const V & QUESO::GaussianVectorRealizer< V, M >::unifiedLawExpVector ( ) const

Access to the vector of mean values and private attribute: m_unifiedLawExpVector.

Definition at line 105 of file GaussianVectorRealizer.C.

106 {
107  return *m_unifiedLawExpVector;
108 }
template<class V , class M >
const V & QUESO::GaussianVectorRealizer< V, M >::unifiedLawVarVector ( ) const

Access to the vector of variance values and private attribute: m_unifiedLawVarVector.

Definition at line 112 of file GaussianVectorRealizer.C.

113 {
114  return *m_unifiedLawVarVector;
115 }
template<class V , class M >
void QUESO::GaussianVectorRealizer< V, M >::updateLawExpVector ( const V &  newLawExpVector)

Updates the mean with the new value newLawExpVector.

Definition at line 148 of file GaussianVectorRealizer.C.

149 {
150  // delete old expected values (allocated at construction or last call to this function)
151  delete m_unifiedLawExpVector;
152 
153  m_unifiedLawExpVector = new V(newLawExpVector);
154 
155  return;
156 }
template<class V , class M >
void QUESO::GaussianVectorRealizer< V, M >::updateLowerCholLawCovMatrix ( const M &  newLowerCholLawCovMatrix)

Updates the lower triangular matrix from Cholesky decomposition of the covariance matrix to the new value newLowerCholLawCovMatrix.

The lower triangular matrix results resulting from a Cholesky decomposition of the covariance matrix. This routine deletes old expected values: m_lowerCholLawCovMatrix; m_matU, m_vecSsqrt, m_matVt.

Definition at line 160 of file GaussianVectorRealizer.C.

161 {
162  // delete old expected values (allocated at construction or last call to this function)
164  delete m_matU;
165  delete m_vecSsqrt;
166  delete m_matVt;
167 
168  m_lowerCholLawCovMatrix = new M(newLowerCholLawCovMatrix);
169  m_matU = NULL;
170  m_vecSsqrt = NULL;
171  m_matVt = NULL;
172 
173  return;
174 }
template<class V , class M >
void QUESO::GaussianVectorRealizer< V, M >::updateLowerCholLawCovMatrix ( const M &  matU,
const V &  vecSsqrt,
const M &  matVt 
)

Updates the SVD matrices from SVD decomposition of the covariance matrix to the new values: matU, vecSsqrt, and matVt.

The lower triangular matrix results resulting from a Cholesky decomposition of the covariance matrix. This routine deletes old expected values: m_lowerCholLawCovMatrix; m_matU, m_vecSsqrt, m_matVt.

Definition at line 178 of file GaussianVectorRealizer.C.

182 {
183  // delete old expected values (allocated at construction or last call to this function)
185  delete m_matU;
186  delete m_vecSsqrt;
187  delete m_matVt;
188 
190  m_matU = new M(matU);
191  m_vecSsqrt = new V(vecSsqrt);
192  m_matVt = new M(matVt);
193 
194  return;
195 }

Member Data Documentation

template<class V, class M>
M* QUESO::GaussianVectorRealizer< V, M >::m_lowerCholLawCovMatrix
private

Definition at line 108 of file GaussianVectorRealizer.h.

template<class V, class M>
M* QUESO::GaussianVectorRealizer< V, M >::m_matU
private

Definition at line 109 of file GaussianVectorRealizer.h.

template<class V, class M>
M* QUESO::GaussianVectorRealizer< V, M >::m_matVt
private

Definition at line 111 of file GaussianVectorRealizer.h.

template<class V, class M>
V* QUESO::GaussianVectorRealizer< V, M >::m_unifiedLawExpVector
private
template<class V, class M>
V* QUESO::GaussianVectorRealizer< V, M >::m_unifiedLawVarVector
private

Definition at line 107 of file GaussianVectorRealizer.h.

template<class V, class M>
V* QUESO::GaussianVectorRealizer< V, M >::m_vecSsqrt
private

Definition at line 110 of file GaussianVectorRealizer.h.


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

Generated on Thu Apr 23 2015 19:26:17 for queso-0.51.1 by  doxygen 1.8.5