queso-0.51.1
MarkovChainPositionData.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,2009,2010,2011,2012,2013 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/MarkovChainPositionData.h>
26 #include <queso/GslVector.h>
27 
28 namespace QUESO {
29 
30 // Constructor 1 -----------------------------------
31 template <class V>
33  :
34  m_env (env),
35  m_vecValues (NULL),
36  m_outOfTargetSupport(false),
37  m_logLikelihood (0.),
38  m_logTarget (0.)
39 {
40 }
41 // Constructor 2 -----------------------------------
42 template <class V>
44  const BaseEnvironment& env,
45  const V& vecValues,
46  bool outOfTargetSupport,
47  double logLikelihood,
48  double logTarget)
49  :
50  m_env (env),
51  m_vecValues (new V(vecValues)),
52  m_outOfTargetSupport(outOfTargetSupport),
53  m_logLikelihood (logLikelihood),
54  m_logTarget (logTarget)
55 {
56 }
57 // Copy constructor---------------------------------
58 template <class V>
60  :
61  m_env (rhs.m_env ),
62  m_vecValues (new V(*rhs.m_vecValues )),
63  m_outOfTargetSupport(rhs.m_outOfTargetSupport),
64  m_logLikelihood (rhs.m_logLikelihood ),
65  m_logTarget (rhs.m_logTarget )
66 {
67 }
68 // Destructor---------------------------------------
69 template <class V>
71 {
72  if (m_vecValues) delete m_vecValues;
73 }
74 // Set methods--------------------------------------
75 template <class V>
78 {
79  if (m_vecValues == NULL) m_vecValues = new V(*rhs.m_vecValues);
80  else *m_vecValues = *rhs.m_vecValues;
81  m_outOfTargetSupport = rhs.m_outOfTargetSupport;
82  m_logLikelihood = rhs.m_logLikelihood;
83  m_logTarget = rhs.m_logTarget;
84 
85  return *this;
86 }
87 
88 // Statistical methods-------------------------------
89 template <class V>
90 const V&
92 {
93  UQ_FATAL_TEST_MACRO((m_vecValues == NULL),
94  m_env.worldRank(),
95  "MarkovChainPositionData<V>::vecValues()",
96  "m_vecValues is NULL");
97  return *m_vecValues;
98 }
99 
100 //--------------------------------------------------
101 template <class V>
102 bool
104 {
105  return m_outOfTargetSupport;
106 }
107 
108 //--------------------------------------------------
109 template <class V>
110 double
112 {
113  return m_logLikelihood;
114 }
115 
116 //--------------------------------------------------
117 template <class V>
118 double
120 {
121  return m_logTarget;
122 }
123 //--------------------------------------------------
124 template <class V>
125 void
127  const V& vecValues,
128  bool outOfTargetSupport,
129  double logLikelihood,
130  double logTarget)
131 {
132  if (m_vecValues == NULL) m_vecValues = new V(vecValues);
133  else *m_vecValues = vecValues;
134  m_outOfTargetSupport = outOfTargetSupport;
135  m_logLikelihood = logLikelihood;
136  m_logTarget = logTarget;
137 
138  return;
139 }
140 
141 } // End namespace QUESO
142 
double logTarget() const
Logarithm of the value of the target; access to private attribute m_logTarget.
const V & vecValues() const
Values of the chain (vector); access to private attribute m_vecValues.
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:187
MarkovChainPositionData< V > & operator=(const MarkovChainPositionData< V > &rhs)
Assignment operator.
double logLikelihood() const
Logarithm of the value of the likelihood; access to private attribute m_logLikelihood.
A templated class that represents a Markov Chain.
bool outOfTargetSupport() const
Whether or not a position is out of target support; access to private attribute m_outOfTargetSupport...
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
void set(const V &vecValues, bool outOfTargetSupport, double logLikelihood, double logTarget)
Sets the values of the chain.
MarkovChainPositionData(const BaseEnvironment &env)
Constructor 1.

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