queso-0.53.0
WignerJointPdf.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2015 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #include <queso/WignerJointPdf.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
28 
29 namespace QUESO {
30 
31 // Constructor -------------------------------------
32 template<class V,class M>
34  const char* prefix,
35  const VectorSet<V,M>& domainSet,
36  const V& centerPos,
37  double radius)
38  :
39  BaseJointPdf<V,M>(((std::string)(prefix)+"uni").c_str(),
40  domainSet),
41  m_centerPos(new V(centerPos)),
42  m_radius (radius)
43 {
44  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
45  *m_env.subDisplayFile() << "Entering WignerJointPdf<V,M>::constructor()"
46  << ": prefix = " << m_prefix
47  << std::endl;
48  }
49 
50  queso_require_greater_msg(m_radius, 0., "invalid radius");
51 
52  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
53  *m_env.subDisplayFile() << "Leaving WignerJointPdf<V,M>::constructor()"
54  << ": prefix = " << m_prefix
55  << std::endl;
56  }
57 }
58 // Destructor --------------------------------------
59 template<class V,class M>
61 {
62  delete m_centerPos;
63 }
64 // Math methods-------------------------------------
65 template<class V, class M>
66 double
68  const V& domainVector,
69  const V* domainDirection,
70  V* gradVector,
71  M* hessianMatrix,
72  V* hessianEffect) const
73 {
74  queso_require_equal_to_msg(domainVector.sizeLocal(), this->m_domainSet.vectorSpace().dimLocal(), "invalid input");
75 
76  if (gradVector ) *gradVector = m_domainSet.vectorSpace().zeroVector();
77  if (hessianMatrix) *hessianMatrix *= 0.;
78  if (hessianEffect) *hessianEffect = m_domainSet.vectorSpace().zeroVector();
79 
80  double returnValue = 0.;
81  double distanceRatio = (domainVector - *m_centerPos).norm2()/m_radius;
82  if (distanceRatio < 1.) {
83  returnValue = 2.*m_radius*m_radius*sqrt(1. - distanceRatio*distanceRatio)/M_PI;
84  }
85  returnValue *= exp(m_logOfNormalizationFactor); // [PDF-09]
86 
87  return returnValue;
88 }
89 //--------------------------------------------------
90 template<class V, class M>
91 double
93  const V& domainVector,
94  const V* domainDirection,
95  V* gradVector,
96  M* hessianMatrix,
97  V* hessianEffect) const
98 {
99  if (gradVector ) *gradVector = m_domainSet.vectorSpace().zeroVector();
100  if (hessianMatrix) *hessianMatrix *= 0.;
101  if (hessianEffect) *hessianEffect = m_domainSet.vectorSpace().zeroVector();
102 
103  // No need to add m_logOfNormalizationFactor because 'actualValue()' is called [PDF-09]
104  return log(this->actualValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect));
105 }
106 //--------------------------------------------------
107 template<class V, class M>
108 double
109 WignerJointPdf<V,M>::computeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
110 {
111  double value = 0.;
112 
113  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
114  *m_env.subDisplayFile() << "Entering WignerJointPdf<V,M>::computeLogOfNormalizationFactor()"
115  << std::endl;
116  }
117  value = BaseJointPdf<V,M>::commonComputeLogOfNormalizationFactor(numSamples, updateFactorInternally);
118  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
119  *m_env.subDisplayFile() << "Leaving WignerJointPdf<V,M>::computeLogOfNormalizationFactor()"
120  << ", m_logOfNormalizationFactor = " << m_logOfNormalizationFactor
121  << std::endl;
122  }
123 
124  return value;
125 }
126 
127 } // End namespace QUESO
128 
~WignerJointPdf()
Destructor.
unsigned int displayVerbosity() const
Definition: Environment.C:396
A templated class for handling sets.
Definition: VectorSet.h:52
WignerJointPdf(const char *prefix, const VectorSet< V, M > &domainSet, const V &centerPos, double radius)
Constructor.
A templated (base) class for handling joint PDFs.
Definition: JointPdf.h:56
double commonComputeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
Common method (to the derived classes) to compute the logarithm of the normalization factor...
Definition: JointPdf.C:77
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
double computeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
Computes the logarithm of the normalization factor.
const BaseEnvironment & m_env
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
A class for handling Wigner joint PDFs.
#define queso_require_greater_msg(expr1, expr2, msg)
Definition: asserts.h:88
double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Actual value of the PDF (scalar function).
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Computes the logarithm of the value of the function.

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