25 #include <queso/ArrayOfOneDTables.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
32 template <
class V,
class M>
37 m_env (rowSpace.env()),
38 m_prefix ((std::string)(prefix)+
""),
39 m_rowSpace (rowSpace ),
40 m_oneDTables(m_rowSpace.map(),1)
48 template <
class V,
class M>
51 for (
unsigned int i = 0; i < (
unsigned int) m_oneDTables.MyLength(); ++i) {
52 if (m_oneDTables(i,0))
delete m_oneDTables(i,0);
57 template <
class V,
class M>
63 "ArrayOfOneDTables<T>::setOneDTable()",
64 "rowId is out of range");
66 if (m_oneDTables(rowId,0) == NULL) m_oneDTables(rowId,0) =
new std::vector<double>(0);
67 else m_oneDTables(rowId,0)->clear();
69 std::vector<double>& vec = *(m_oneDTables(rowId,0));
70 vec.resize(values.size(),0.);
71 for (
unsigned int j = 0; j < values.size(); ++j) {
78 template <
class V,
class M>
79 const std::vector<double>&
84 "ArrayOfOneDTables<T>::oneDTable()",
85 "rowId is out of range");
91 "ArrayOfOneDTables<T>::oneDTable()",
92 "requested row is still NULL");
94 return *(tmp->m_oneDTables(rowId,0));
98 template <
class V,
class M>
103 for (
unsigned int i = 0; i < (
unsigned int) m_oneDTables.MyLength(); ++i) {
104 const std::vector<double>& tmpVec = *(tmp->
m_oneDTables(i,0));
105 os << m_prefix << i <<
"_values_sub" << m_env.subIdString() <<
" = zeros(" << tmpVec.size()
109 os << m_prefix << i <<
"_values_sub" << m_env.subIdString() <<
" = [";
110 for (
unsigned int j = 0; j < tmpVec.size(); ++j) {
111 os << tmpVec[j] <<
" ";
120 template <
class V,
class M>
121 std::ostream& operator<< (std::ostream& os, const ArrayOfOneDTables<V,M>& obj)
DistArray< std::vector< double > * > m_oneDTables
const std::vector< double > & oneDTable(unsigned int rowId) const
Returns the array located at position rowId of the one-dimensional table.
int MyLength() const
Returns the length of the locally owned array.
ArrayOfOneDTables(const char *prefix, const VectorSpace< V, M > &rowSpace)
Default constructor.
~ArrayOfOneDTables()
Destructor.
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
void setOneDTable(unsigned int rowId, const std::vector< double > &values)
Sets the one-dimensional table.
Class to accommodate arrays of one-dimensional tables.
A class representing a vector space.
void print(std::ostream &os) const
Prints the values in this array of tables.