queso-0.53.0
ConcatenatedVectorRV.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/ConcatenatedVectorRV.h>
26 #include <queso/ConcatenatedVectorRealizer.h>
27 #include <queso/ConcatenatedJointPdf.h>
28 #include <queso/GslVector.h>
29 #include <queso/GslMatrix.h>
30 
31 namespace QUESO {
32 
33 // Constructor -------------------------------------
34 template<class V, class M>
36  const char* prefix,
37  const BaseVectorRV<V,M>& rv1,
38  const BaseVectorRV<V,M>& rv2,
39  const VectorSet<V,M>& imageSet)
40  :
41  BaseVectorRV<V,M>(((std::string)(prefix)+"concat").c_str(),imageSet),
42  m_rvs (2,(const BaseVectorRV <V,M>*) NULL),
43  m_pdfs (2,(const BaseJointPdf <V,M>*) NULL),
44  m_realizers (2,(const BaseVectorRealizer<V,M>*) NULL)
45 {
46  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
47  *m_env.subDisplayFile() << "Entering ConcatenatedVectorRV<V,M>::constructor(1)"
48  << ": prefix = " << m_prefix
49  << std::endl;
50  }
51 
52  m_rvs[0] = &rv1;
53  m_rvs[1] = &rv2;
54  m_pdfs[0] = &(m_rvs[0]->pdf());
55  m_pdfs[1] = &(m_rvs[1]->pdf());
56  m_realizers[0] = &(m_rvs[0]->realizer());
57  m_realizers[1] = &(m_rvs[1]->realizer());
58 
60  *(m_pdfs[0]),
61  *(m_pdfs[1]),
62  m_imageSet);
63 
65  *(m_realizers[0]),
66  *(m_realizers[1]),
67  m_imageSet);
68  m_subCdf = NULL; // FIX ME: complete code
69  m_unifiedCdf = NULL; // FIX ME: complete code
70  m_mdf = NULL; // FIX ME: complete code
71 
72  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
73  *m_env.subDisplayFile() << "Leaving ConcatenatedVectorRV<V,M>::constructor(1)"
74  << ": prefix = " << m_prefix
75  << std::endl;
76  }
77 }
78 // Constructor -------------------------------------
79 template<class V, class M>
81  const char* prefix,
82  const std::vector<const BaseVectorRV<V,M>* >& rvs,
83  const VectorSet<V,M>& imageSet)
84  :
85  BaseVectorRV<V,M>(((std::string)(prefix)+"concat").c_str(),imageSet),
86  m_rvs (rvs.size(),(const BaseVectorRV <V,M>*) NULL),
87  m_pdfs (rvs.size(),(const BaseJointPdf <V,M>*) NULL),
88  m_realizers (rvs.size(),(const BaseVectorRealizer<V,M>*) NULL)
89 {
90  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
91  *m_env.subDisplayFile() << "Entering ConcatenatedVectorRV<V,M>::constructor(2)"
92  << ": prefix = " << m_prefix
93  << std::endl;
94  }
95 
96  for (unsigned int i = 0; i < m_rvs.size(); ++i) {
97  m_rvs [i] = rvs[i];
98  m_pdfs[i] = &(m_rvs[i]->pdf());
99  m_realizers[i] = &(m_rvs[i]->realizer());
100  }
101 
103  m_pdfs,
104  m_imageSet);
105 
106  unsigned int minPeriod = m_realizers[0]->subPeriod();
107  for (unsigned int i = 0; i < m_realizers.size(); ++i) {
108  if (minPeriod > m_realizers[i]->subPeriod()) {
109  minPeriod = m_realizers[i]->subPeriod();
110  }
111  }
112 
114  m_realizers,
115  minPeriod,
116  m_imageSet);
117  m_subCdf = NULL; // FIX ME: complete code
118  m_unifiedCdf = NULL; // FIX ME: complete code
119  m_mdf = NULL; // FIX ME: complete code
120 
121  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
122  *m_env.subDisplayFile() << "Leaving ConcatenatedVectorRV<V,M>::constructor(2)"
123  << ": prefix = " << m_prefix
124  << std::endl;
125  }
126 }
127 // Destructor --------------------------------------
128 template<class V, class M>
130 {
131  delete m_mdf;
132  delete m_unifiedCdf;
133  delete m_subCdf;
134  delete m_realizer;
135  delete m_pdf;
136 }
137 //--------------------------------------------------
138 template <class V, class M>
139 void
140 ConcatenatedVectorRV<V,M>::print(std::ostream& os) const
141 {
142  os << "ConcatenatedVectorRV<V,M>::print() says, 'Please implement me.'" << std::endl;
143  return;
144 }
145 
146 } // End namespace QUESO
147 
unsigned int displayVerbosity() const
Definition: Environment.C:396
A templated class for handling sets.
Definition: VectorSet.h:52
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:117
A class for handling sampling from concatenated probability density distributions.
A templated base class for handling vector RV.
Definition: VectorRV.h:54
virtual ~ConcatenatedVectorRV()
Virtual destructor.
A templated (base) class for handling joint PDFs.
Definition: JointPdf.h:56
ConcatenatedVectorRV(const char *prefix, const BaseVectorRV< V, M > &rv1, const BaseVectorRV< V, M > &rv2, const VectorSet< V, M > &imageSet)
Constructor.
std::vector< const BaseVectorRV< V, M > * > m_rvs
void print(std::ostream &os) const
TODO: Prints the vector RV.
std::vector< const BaseJointPdf< V, M > * > m_pdfs
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:118
std::string m_prefix
Definition: VectorRV.h:116
A class for handling concatenated PDFs.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
A templated (base) class for handling sampling from vector RVs.
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:121
const BaseEnvironment & m_env
Definition: VectorRV.h:115
const BaseVectorMdf< V, M > * m_mdf
Definition: VectorRV.h:122
std::vector< const BaseVectorRealizer< V, M > * > m_realizers
A class representing concatenated vector RVs.
const BaseVectorCdf< V, M > * m_subCdf
Definition: VectorRV.h:120
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:119

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