queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::SampledVectorCdf< V, M > Class Template Reference

A class for handling sampled vector CDFs. More...

#include <SampledVectorCdf.h>

Inheritance diagram for QUESO::SampledVectorCdf< V, M >:
QUESO::BaseVectorCdf< V, M >

Public Member Functions

Constructor/Destructor methods
 SampledVectorCdf (const char *prefix, const ArrayOfOneDGrids< V, M > &oneDGrids, const ArrayOfOneDTables< V, M > &cdfValues)
 Default constructor. More...
 
 ~SampledVectorCdf ()
 Destructor. More...
 
Mathematical methods
void values (const V &paramValues, V &cdfVec) const
 TODO: Returns the values of the vector CDF at each element of paramValues. More...
 
const BaseScalarCdf< double > & cdf (unsigned int rowId) const
 Returns a scalar CDF stored at row rowId of the vector CDF. More...
 
I/O methods
void print (std::ostream &os) const
 Prints the vector CDF (values of the grid points and of the CDF at such grid points). More...
 
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. More...
 
- Public Member Functions inherited from QUESO::BaseVectorCdf< V, M >
 BaseVectorCdf (const char *prefix, const VectorSet< V, M > &pdfSupport)
 Default constructor. More...
 
virtual ~BaseVectorCdf ()
 Virtual destructor. More...
 
const VectorSet< V, M > & pdfSupport () const
 Returns the image set (support) of the PDF; access to protected attribute m_pdfSupport. More...
 

Protected Attributes

DistArray< SampledScalarCdf
< double > * > 
m_cdfs
 
- Protected Attributes inherited from QUESO::BaseVectorCdf< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSet< V, M > & m_pdfSupport
 

Detailed Description

template<class V = GslVector, class M = GslMatrix>
class QUESO::SampledVectorCdf< V, M >

A class for handling sampled vector CDFs.

This class implements a sampled vector cumulative distribution function (CDF), given the grid points where it will be sampled and it returns its values.

Definition at line 51 of file SampledVectorCdf.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::SampledVectorCdf< V, M >::SampledVectorCdf ( const char *  prefix,
const ArrayOfOneDGrids< V, M > &  oneDGrids,
const ArrayOfOneDTables< V, M > &  cdfValues 
)

Default constructor.

Instantiates an object of the class given a prefix and the grid points where it will be sampled/evaluated.

Definition at line 31 of file SampledVectorCdf.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::ArrayOfOneDGrids< V, M >::grid(), QUESO::SampledVectorCdf< V, M >::m_cdfs, QUESO::BaseVectorCdf< V, M >::m_env, QUESO::BaseVectorCdf< V, M >::m_prefix, QUESO::ArrayOfOneDTables< V, M >::oneDTable(), and QUESO::BaseEnvironment::subDisplayFile().

35  :
36  BaseVectorCdf<V,M>(prefix,oneDGrids.rowSpace()),
37  m_cdfs(m_pdfSupport.vectorSpace().map(),1)
38 {
39  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
40  *m_env.subDisplayFile() << "Entering SampledVectorCdf<V,M>::constructor()"
41  << ": prefix = " << m_prefix
42  << std::endl;
43  }
44 
45  char strI[65];
46  for (unsigned int i = 0; i < (unsigned int) m_cdfs.MyLength(); ++i) {
47  sprintf(strI,"%u_",i);
48  m_cdfs(i,0) = new SampledScalarCdf<double>(m_env,
49  ((std::string)(m_prefix)+strI).c_str(),
50  oneDGrids.grid(i),
51  cdfValues.oneDTable(i));
52  }
53 
54  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
55  *m_env.subDisplayFile() << "Leaving SampledVectorCdf<V,M>::constructor()"
56  << ": prefix = " << m_prefix
57  << std::endl;
58  }
59 }
std::string m_prefix
Definition: VectorCdf.h:99
DistArray< SampledScalarCdf< double > * > m_cdfs
const VectorSet< V, M > & m_pdfSupport
Definition: VectorCdf.h:100
const BaseEnvironment & m_env
Definition: VectorCdf.h:98
unsigned int displayVerbosity() const
Definition: Environment.C:450
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
QUESO::SampledVectorCdf< V, M >::~SampledVectorCdf ( )

Destructor.

Definition at line 62 of file SampledVectorCdf.C.

63 {
64  for (unsigned int i = 0; i < (unsigned int) m_cdfs.MyLength(); ++i) {
65  if (m_cdfs(i,0)) delete m_cdfs(i,0);
66  }
67 }
DistArray< SampledScalarCdf< double > * > m_cdfs

Member Function Documentation

template<class V , class M >
const BaseScalarCdf< double > & QUESO::SampledVectorCdf< V, M >::cdf ( unsigned int  rowId) const
virtual

Returns a scalar CDF stored at row rowId of the vector CDF.

Implements QUESO::BaseVectorCdf< V, M >.

Definition at line 81 of file SampledVectorCdf.C.

82 {
83  queso_require_less_msg(rowId, m_pdfSupport.vectorSpace().dimLocal(), "rowId is out of range");
84 
85  SampledVectorCdf<V,M>* tmp = const_cast<SampledVectorCdf<V,M>*>(this);
86  return *(tmp->m_cdfs(rowId,0));
87 
88 }
const VectorSet< V, M > & m_pdfSupport
Definition: VectorCdf.h:100
template<class V , class M >
void QUESO::SampledVectorCdf< V, M >::print ( std::ostream &  os) const
virtual

Prints the vector CDF (values of the grid points and of the CDF at such grid points).

Implements QUESO::BaseVectorCdf< V, M >.

Definition at line 92 of file SampledVectorCdf.C.

References QUESO::SampledVectorCdf< V, M >::m_cdfs.

93 {
94  SampledVectorCdf<V,M>* tmp = const_cast<SampledVectorCdf<V,M>*>(this);
95  for (unsigned int i = 0; i < (unsigned int) m_cdfs.MyLength(); ++i) {
96  os << (*tmp->m_cdfs(i,0))
97  << std::endl;
98  }
99 
100  return;
101 }
DistArray< SampledScalarCdf< double > * > m_cdfs
template<class V , class M >
void QUESO::SampledVectorCdf< V, M >::subWriteContents ( const std::string &  varNamePrefix,
const std::string &  fileName,
const std::string &  fileType,
const std::set< unsigned int > &  allowedSubEnvIds 
) const
virtual

Writes the CDF of an allowed sub-environment to a file.

Reimplemented from QUESO::BaseVectorCdf< V, M >.

Definition at line 105 of file SampledVectorCdf.C.

110 {
111  queso_require_greater_equal_msg(m_env.subRank(), 0, "unexpected subRank");
112 
113  SampledVectorCdf<V,M>* tmp = const_cast<SampledVectorCdf<V,M>*>(this);
114  char compId[16+1];
115  for (unsigned int i = 0; i < (unsigned int) m_cdfs.MyLength(); ++i) {
116  sprintf(compId,"%d",i);
117  tmp->m_cdfs(i,0)->subWriteContents(varNamePrefix+"comp"+compId,fileName,fileType,allowedSubEnvIds);
118  }
119 
120  return;
121 }
DistArray< SampledScalarCdf< double > * > m_cdfs
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
const BaseEnvironment & m_env
Definition: VectorCdf.h:98
template<class V , class M >
void QUESO::SampledVectorCdf< V, M >::values ( const V &  paramValues,
V &  cdfVec 
) const
virtual

TODO: Returns the values of the vector CDF at each element of paramValues.

Todo:
: implement me!

Implements QUESO::BaseVectorCdf< V, M >.

Definition at line 71 of file SampledVectorCdf.C.

74 {
75  queso_error_msg("incomplete code");
76  return;
77 }

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
DistArray<SampledScalarCdf<double>*> QUESO::SampledVectorCdf< V, M >::m_cdfs
protected

The documentation for this class was generated from the following files:

Generated on Tue Jun 5 2018 19:49:35 for queso-0.57.1 by  doxygen 1.8.5