queso-0.53.0
TKGroup.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/TKGroup.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
28 
29 namespace QUESO {
30 
31 // Default constructor ------------------------------
32 template<class V, class M>
34  :
35  m_emptyEnv (new EmptyEnvironment()),
36  m_env (*m_emptyEnv),
37  m_prefix (""),
38  m_vectorSpace (NULL),
39  m_scales (0),
40  m_preComputingPositions(NULL),
41  m_rvs (0)
42 {
43 }
44 // Constructor with values---------------------------
45 template<class V, class M>
47  const char* prefix,
48  const VectorSpace<V,M>& vectorSpace,
49  const std::vector<double>& scales)
50  :
51  m_emptyEnv (NULL),
52  m_env (vectorSpace.env()),
53  m_prefix (prefix),
54  m_vectorSpace (&vectorSpace),
55  m_scales (scales.size(),1.),
56  m_preComputingPositions(scales.size()+1,NULL), // Yes, +1
57  m_rvs (scales.size(),NULL) // IMPORTANT: it stays like this for scaledTK, but it will be overwritten to '+1' by hessianTK constructor
58 {
59  for (unsigned int i = 0; i < m_scales.size(); ++i) {
60  m_scales[i] = scales[i];
61  }
62 }
63 // Destructor ---------------------------------------
64 template<class V, class M>
66 {
67  for (unsigned int i = 0; i < m_rvs.size(); ++i) {
68  if (m_rvs[i]) delete m_rvs[i];
69  }
70  for (unsigned int i = 0; i < m_preComputingPositions.size(); ++i) {
71  if (m_preComputingPositions[i]) delete m_preComputingPositions[i];
72  }
73  if (m_emptyEnv) delete m_emptyEnv;
74 }
75 // Misc methods--------------------------------------
76 template<class V, class M>
77 const BaseEnvironment&
79 {
80  return m_env;
81 }
82 //---------------------------------------------------
83 template<class V, class M>
84 const V&
85 BaseTKGroup<V,M>::preComputingPosition(unsigned int stageId) const
86 {
87  queso_require_greater_msg(m_preComputingPositions.size(), stageId, "m_preComputingPositions.size() <= stageId");
88 
89  queso_require_msg(m_preComputingPositions[stageId], "m_preComputingPositions[stageId] == NULL");
90 
91  return *m_preComputingPositions[stageId];
92 }
93 //---------------------------------------------------
94 template<class V, class M>
95 bool
96 BaseTKGroup<V,M>::setPreComputingPosition(const V& position, unsigned int stageId)
97 {
98  queso_require_greater_msg(m_preComputingPositions.size(), stageId, "m_preComputingPositions.size() <= stageId");
99 
100  queso_require_msg(!(m_preComputingPositions[stageId]), "m_preComputingPositions[stageId] != NULL");
101 
102  m_preComputingPositions[stageId] = new V(position);
103 
104  return true;
105 }
106 //---------------------------------------------------
107 template<class V, class M>
108 void
110 {
111  for (unsigned int i = 0; i < m_preComputingPositions.size(); ++i) {
112  if (m_preComputingPositions[i]) {
113  delete m_preComputingPositions[i];
114  m_preComputingPositions[i] = NULL;
115  }
116  }
117 
118  return;
119 }
120 // I/O methods---------------------------------------
121 template<class V, class M>
122 void
123 BaseTKGroup<V,M>::print(std::ostream& os) const
124 {
125  os << "In BaseTKGroup<V,M>::print()"
126  << ": nothing to be printed" << std::endl;
127  return;
128 }
129 
130 } // End namespace QUESO
131 
virtual void print(std::ostream &os) const
TODO: Prints the transition kernel.
Definition: TKGroup.C:123
This class sets up the environment underlying the use of the QUESO library by an executable.
Definition: Environment.h:392
This base class allows the representation of a transition kernel.
Definition: TKGroup.h:50
virtual ~BaseTKGroup()
Destructor.
Definition: TKGroup.C:65
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:96
virtual void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId].
Definition: TKGroup.C:109
const BaseEnvironment & env() const
QUESO&#39;s environment.
Definition: TKGroup.C:78
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:193
BaseTKGroup()
Default constructor.
Definition: TKGroup.C:33
std::vector< double > m_scales
Definition: TKGroup.h:103
const V & preComputingPosition(unsigned int stageId) const
Pre-computing position; access to protected attribute *m_preComputingPositions[stageId].
Definition: TKGroup.C:85
#define queso_require_greater_msg(expr1, expr2, msg)
Definition: asserts.h:88
A class representing a vector space.
Definition: VectorSet.h:49

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