queso-0.53.0
StdScalarCdf.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/StdScalarCdf.h>
26 
27 namespace QUESO {
28 
29 // Default constructor -----------------------------
30 template<class T>
32  const BaseEnvironment& env,
33  const char* prefix,
34  const std::vector<T>& cdfGrid,
35  const std::vector<double>& cdfValues)
36  :
37  BaseScalarCdf<T>(env,((std::string)(prefix)+"").c_str()),
38  m_cdfGrid (env,prefix,cdfGrid),
39  m_cdfValues (cdfValues),
40  m_sampledCdfGrid (NULL)
41 {
42  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
43  *m_env.subDisplayFile() << "Entering StdScalarCdf<T>::constructor()"
44  << ": prefix = " << m_prefix
45  << std::endl;
46  }
47 
49 
50  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
51  *m_env.subDisplayFile() << "Leaving StdScalarCdf<T>::constructor()"
52  << ": prefix = " << m_prefix
53  << std::endl;
54  }
55 }
56 // Destructor ---------------------------------------
57 template<class T>
59 {
60  delete m_sampledCdfGrid;
61 }
62 // Math methods--------------------------------------
63 template<class T>
64 double
65 StdScalarCdf<T>::value(T paramValue) const
66 {
67  return m_sampledCdfGrid->value(paramValue);
68 }
69 //---------------------------------------------------
70 template<class T>
71 T
72 StdScalarCdf<T>::inverse(double cdfValue) const
73 {
74  return m_sampledCdfGrid->inverse(cdfValue);
75 }
76 //---------------------------------------------------
77 template<class T>
78 void
79 StdScalarCdf<T>::getSupport(T& minHorizontal, T& maxHorizontal) const
80 {
81  return m_sampledCdfGrid->getSupport(minHorizontal,maxHorizontal);
82 }
83 // I/O methods---------------------------------------
84 template <class T>
85 void
86 StdScalarCdf<T>::print(std::ostream& os) const
87 {
88  m_sampledCdfGrid->print(os);
89  return;
90 }
91 //---------------------------------------------------
92 template<class T>
93 void
95  const std::string& varNamePrefix,
96  const std::string& fileName,
97  const std::string& fileType,
98  const std::set<unsigned int>& allowedSubEnvIds) const
99 {
100  m_sampledCdfGrid->subWriteContents(varNamePrefix,fileName,fileType,allowedSubEnvIds);
101  return;
102 }
103 
104 } // End namespace QUESO
unsigned int displayVerbosity() const
Definition: Environment.C:396
SampledScalarCdf< T > * m_sampledCdfGrid
Definition: StdScalarCdf.h:95
A templated (base) class for handling CDFs.
Definition: ScalarCdf.h:49
const BaseEnvironment & m_env
Definition: ScalarCdf.h:99
T inverse(double cdfValue) const
Returns the position of a given value of CDF.
Definition: StdScalarCdf.C:72
std::string m_prefix
Definition: ScalarCdf.h:100
const std::vector< double > m_cdfValues
Definition: StdScalarCdf.h:94
double value(T paramValue) const
Returns the value of the CDF at paramValue.
Definition: StdScalarCdf.C:65
const std::string & prefix() const
Access to private attribute m_prefix.
Definition: ScalarCdf.C:67
StdScalarCdf(const BaseEnvironment &env, const char *prefix, const std::vector< T > &cdfGrid, const std::vector< double > &cdfValues)
Default constructor.
Definition: StdScalarCdf.C:31
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:193
void getSupport(T &minHorizontal, T &maxHorizontal) const
Returns the support (image) of the CDF between two horizontal values (domain).
Definition: StdScalarCdf.C:79
void print(std::ostream &os) const
Prints the CDF (values of the grid points and of the CDF at such grid points).
Definition: StdScalarCdf.C:86
const StdOneDGrid< T > m_cdfGrid
Definition: StdScalarCdf.h:93
~StdScalarCdf()
Destructor.
Definition: StdScalarCdf.C:58
A class for handling sampled CDFs.
const BaseEnvironment & env() const
Environment. Access to private attribute m_env.
Definition: ScalarCdf.C:60
void subWriteContents(const std::string &varNamePrefix, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
Writes the CDF of an allowed sub-environment to a file.
Definition: StdScalarCdf.C:94

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