queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
SequentialVectorRealizer.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-2017 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/SequentialVectorRealizer.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 BaseVectorSequence<V,M>& chain)
36  :
37  BaseVectorRealizer<V,M>(((std::string)(prefix)+"seq").c_str(),chain.unifiedBoxPlain(),chain.subSequenceSize()),
38  m_chain (chain),
39  m_currentChainPos (0),
40  m_unifiedSampleExpVector(new V(chain.unifiedMeanPlain() )), // IMPORTANT
41  m_unifiedSampleVarVector(new V(chain.unifiedSampleVariancePlain())) // IMPORTANT
42 {
43  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 0)) {
44  *m_env.subDisplayFile() << "In SequentialVectorRealizer<V,M>::constructor()"
45  << ": m_chain.subSequenceSize() = " << m_chain.subSequenceSize()
46  << std::endl;
47  }
48 }
49 // Destructor --------------------------------------
50 template<class V, class M>
52 {
53  delete m_unifiedSampleVarVector;
54  delete m_unifiedSampleExpVector;
55 }
56 // Realization-related methods----------------------
57 template<class V, class M>
58 void
60 {
61  m_chain.getPositionValues(m_currentChainPos++,nextParamValues);
62  if (m_currentChainPos >= m_subPeriod) m_currentChainPos = 0;
63 
64  return;
65 }
66 //--------------------------------------------------
67 template <class V, class M>
68 const V&
70 {
71  return *m_unifiedSampleExpVector;
72 }
73 //--------------------------------------------------
74 template <class V, class M>
75 const V&
77 {
78  return *m_unifiedSampleVarVector;
79 }
80 
81 } // End namespace QUESO
82 
A templated (base) class for handling sampling from vector RVs.
const BaseVectorSequence< V, M > & m_chain
const BaseEnvironment & m_env
const V & unifiedSampleVarVector() const
Returns the unified variance vector; access to private attribute m_unifiedSampleVarVector.
SequentialVectorRealizer(const char *prefix, const BaseVectorSequence< V, M > &chain)
void realization(V &nextValues) const
Draws the next value from this chain (m_chain) and saves it in nextValues.
Base class for handling vector and array samples (sequence of vectors or arrays). ...
unsigned int displayVerbosity() const
Definition: Environment.C:450
A class for handling sequential draws (sampling) from probability density distributions.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320

Generated on Tue Jun 5 2018 19:48:56 for queso-0.57.1 by  doxygen 1.8.5