queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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 >:
QUESO::BaseVectorRealizer< V, M >

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 = GslVector, class M = GslMatrix>
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 48 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 34 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().

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

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

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 120 of file GaussianVectorRealizer.C.

121 {
122  V iidGaussianVector(m_unifiedImageSet.vectorSpace().zeroVector());
123 
124  bool outOfSupport = true;
125  do {
126  iidGaussianVector.cwSetGaussian(0.0, 1.0);
127 
129  nextValues = (*m_unifiedLawExpVector) + (*m_lowerCholLawCovMatrix)*iidGaussianVector;
130  }
131  else if (m_matU && m_vecSsqrt && m_matVt) {
132  nextValues = (*m_unifiedLawExpVector) + (*m_matU)*( (*m_vecSsqrt) * ((*m_matVt)*iidGaussianVector) );
133  }
134  else {
135  queso_error_msg("inconsistent internal state");
136  }
137 
138  outOfSupport = !(this->m_unifiedImageSet.contains(nextValues));
139  } while (outOfSupport); // prudenci 2011-Oct-04
140 
141  return;
142 }
const VectorSet< V, M > & m_unifiedImageSet
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 106 of file GaussianVectorRealizer.C.

107 {
108  return *m_unifiedLawExpVector;
109 }
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 113 of file GaussianVectorRealizer.C.

114 {
115  return *m_unifiedLawVarVector;
116 }
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 146 of file GaussianVectorRealizer.C.

147 {
148  // delete old expected values (allocated at construction or last call to this function)
149  delete m_unifiedLawExpVector;
150 
151  m_unifiedLawExpVector = new V(newLawExpVector);
152 
153  return;
154 }
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 158 of file GaussianVectorRealizer.C.

159 {
160  // delete old expected values (allocated at construction or last call to this function)
162  delete m_matU;
163  delete m_vecSsqrt;
164  delete m_matVt;
165 
166  m_lowerCholLawCovMatrix = new M(newLowerCholLawCovMatrix);
167  m_matU = NULL;
168  m_vecSsqrt = NULL;
169  m_matVt = NULL;
170 
171  return;
172 }
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 176 of file GaussianVectorRealizer.C.

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

Member Data Documentation

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

Definition at line 111 of file GaussianVectorRealizer.h.

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

Definition at line 112 of file GaussianVectorRealizer.h.

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

Definition at line 114 of file GaussianVectorRealizer.h.

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

Definition at line 110 of file GaussianVectorRealizer.h.

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

Definition at line 113 of file GaussianVectorRealizer.h.


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

Generated on Tue Jun 5 2018 19:49:27 for queso-0.57.1 by  doxygen 1.8.5