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

Class to accommodate arrays of one-dimensional tables. More...

#include <ArrayOfOneDTables.h>

Public Member Functions

Constructor/Destructor methods
 ArrayOfOneDTables (const char *prefix, const VectorSpace< V, M > &rowSpace)
 Default constructor. More...
 
 ~ArrayOfOneDTables ()
 Destructor. More...
 
Math methods
void setOneDTable (unsigned int rowId, const std::vector< double > &values)
 Sets the one-dimensional table. More...
 
const std::vector< double > & oneDTable (unsigned int rowId) const
 Returns the array located at position rowId of the one-dimensional table. More...
 
I/O method
void print (std::ostream &os) const
 Prints the values in this array of tables. More...
 

Private Attributes

const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSpace< V, M > & m_rowSpace
 
DistArray< std::vector< double > * > m_oneDTables
 

Detailed Description

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

Class to accommodate arrays of one-dimensional tables.

Arrays of one-dimensional tables are necessary in the calculation (storage), for instance, of CDFs and MDF of vector functions (refer to BaseVectorCdf, BaseVectorMdf, and derived classes) given the (array of) grid points (ArrayOfOneDGrids).

Definition at line 49 of file ArrayOfOneDTables.h.

Constructor & Destructor Documentation

template<class V, class M>
QUESO::ArrayOfOneDTables< V, M >::ArrayOfOneDTables ( const char *  prefix,
const VectorSpace< V, M > &  rowSpace 
)

Default constructor.

Definition at line 33 of file ArrayOfOneDTables.C.

References QUESO::ArrayOfOneDTables< V, M >::m_oneDTables, and QUESO::DistArray< T >::MyLength().

36  :
37  m_env (rowSpace.env()),
38  m_prefix ((std::string)(prefix)+""),
39  m_rowSpace (rowSpace ),
40  m_oneDTables(m_rowSpace.map(),1)
41 {
42  for (unsigned int i = 0; i < (unsigned int) m_oneDTables.MyLength(); ++i) {
43  m_oneDTables(i,0) = NULL;
44  }
45 }
const BaseEnvironment & m_env
const VectorSpace< V, M > & m_rowSpace
int MyLength() const
Returns the length of the locally owned array.
Definition: DistArray.C:118
DistArray< std::vector< double > * > m_oneDTables
template<class V , class M >
QUESO::ArrayOfOneDTables< V, M >::~ArrayOfOneDTables ( )

Destructor.

Definition at line 49 of file ArrayOfOneDTables.C.

50 {
51  for (unsigned int i = 0; i < (unsigned int) m_oneDTables.MyLength(); ++i) {
52  if (m_oneDTables(i,0)) delete m_oneDTables(i,0);
53  }
54 }
int MyLength() const
Returns the length of the locally owned array.
Definition: DistArray.C:118
DistArray< std::vector< double > * > m_oneDTables

Member Function Documentation

template<class V , class M >
const std::vector< double > & QUESO::ArrayOfOneDTables< V, M >::oneDTable ( unsigned int  rowId) const

Returns the array located at position rowId of the one-dimensional table.

Definition at line 77 of file ArrayOfOneDTables.C.

Referenced by QUESO::SampledVectorCdf< V, M >::SampledVectorCdf().

78 {
79  queso_require_less_msg(rowId, (unsigned int) m_oneDTables.MyLength(), "rowId is out of range");
80 
81  ArrayOfOneDTables<V,M>* tmp = const_cast<ArrayOfOneDTables<V,M>*>(this);
82 
83  queso_require_msg(tmp->m_oneDTables(rowId,0), "requested row is still NULL");
84 
85  return *(tmp->m_oneDTables(rowId,0));
86 }
int MyLength() const
Returns the length of the locally owned array.
Definition: DistArray.C:118
DistArray< std::vector< double > * > m_oneDTables
template<class V , class M >
void QUESO::ArrayOfOneDTables< V, M >::print ( std::ostream &  os) const

Prints the values in this array of tables.

It prints the arrays (inner for-loop) in each position of the table (outer for-loop).

Definition at line 91 of file ArrayOfOneDTables.C.

References QUESO::ArrayOfOneDTables< V, M >::m_oneDTables.

Referenced by QUESO::operator<<().

92 {
93  ArrayOfOneDTables<V,M>* tmp = const_cast<ArrayOfOneDTables<V,M>*>(this);
94  for (unsigned int i = 0; i < (unsigned int) m_oneDTables.MyLength(); ++i) {
95  const std::vector<double>& tmpVec = *(tmp->m_oneDTables(i,0));
96  os << m_prefix << i << "_values_sub" << m_env.subIdString() << " = zeros(" << tmpVec.size()
97  << "," << 1
98  << ");"
99  << std::endl;
100  os << m_prefix << i << "_values_sub" << m_env.subIdString() << " = [";
101  for (unsigned int j = 0; j < tmpVec.size(); ++j) {
102  os << tmpVec[j] << " ";
103  }
104  os << "];"
105  << std::endl;
106  }
107 
108  return;
109 }
const BaseEnvironment & m_env
int MyLength() const
Returns the length of the locally owned array.
Definition: DistArray.C:118
DistArray< std::vector< double > * > m_oneDTables
const std::string & subIdString() const
Access to the attribute m_subIdString; which stores the string for the sub-environment, and it will be used, for instance, to create the output files for each sub-environment.
Definition: Environment.C:348
template<class V , class M >
void QUESO::ArrayOfOneDTables< V, M >::setOneDTable ( unsigned int  rowId,
const std::vector< double > &  values 
)

Sets the one-dimensional table.

This methods assigns the array values to position rowId of the one-dimensional table.

Definition at line 59 of file ArrayOfOneDTables.C.

Referenced by QUESO::SequenceOfVectors< V, M >::subUniformlySampledCdf(), QUESO::SequenceOfVectors< V, M >::subUniformlySampledMdf(), QUESO::SequenceOfVectors< V, M >::unifiedUniformlySampledCdf(), and QUESO::ArrayOfSequences< V, M >::uniformlySampledCdf().

60 {
61  queso_require_less_msg(rowId, (unsigned int) m_oneDTables.MyLength(), "rowId is out of range");
62 
63  if (m_oneDTables(rowId,0) == NULL) m_oneDTables(rowId,0) = new std::vector<double>(0);
64  else m_oneDTables(rowId,0)->clear();
65 
66  std::vector<double>& vec = *(m_oneDTables(rowId,0));
67  vec.resize(values.size(),0.);
68  for (unsigned int j = 0; j < values.size(); ++j) {
69  vec[j] = values[j];
70  }
71 
72  return;
73 }
int MyLength() const
Returns the length of the locally owned array.
Definition: DistArray.C:118
DistArray< std::vector< double > * > m_oneDTables

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
const BaseEnvironment& QUESO::ArrayOfOneDTables< V, M >::m_env
private

Definition at line 78 of file ArrayOfOneDTables.h.

template<class V = GslVector, class M = GslMatrix>
DistArray<std::vector<double>*> QUESO::ArrayOfOneDTables< V, M >::m_oneDTables
private
template<class V = GslVector, class M = GslMatrix>
std::string QUESO::ArrayOfOneDTables< V, M >::m_prefix
private

Definition at line 79 of file ArrayOfOneDTables.h.

template<class V = GslVector, class M = GslMatrix>
const VectorSpace<V,M>& QUESO::ArrayOfOneDTables< V, M >::m_rowSpace
private

Definition at line 80 of file ArrayOfOneDTables.h.


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

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