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>
61 queso_require_less_msg(rowId, (
unsigned int) m_oneDTables.MyLength(),
"rowId is out of range");
63 if (m_oneDTables(rowId,0) == NULL) m_oneDTables(rowId,0) =
new std::vector<double>(0);
64 else m_oneDTables(rowId,0)->clear();
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) {
75 template <
class V,
class M>
76 const std::vector<double>&
79 queso_require_less_msg(rowId, (
unsigned int) m_oneDTables.MyLength(),
"rowId is out of range");
83 queso_require_msg(tmp->m_oneDTables(rowId,0),
"requested row is still NULL");
85 return *(tmp->m_oneDTables(rowId,0));
89 template <
class V,
class M>
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()
100 os << m_prefix << i <<
"_values_sub" << m_env.subIdString() <<
" = [";
101 for (
unsigned int j = 0; j < tmpVec.size(); ++j) {
102 os << tmpVec[j] <<
" ";
111 template <
class V,
class M>
112 std::ostream& operator<< (std::ostream& os, const ArrayOfOneDTables<V,M>& obj)
A class representing a vector space.
Class to accommodate arrays of one-dimensional tables.
void setOneDTable(unsigned int rowId, const std::vector< double > &values)
Sets the one-dimensional table.
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.
DistArray< std::vector< double > * > m_oneDTables
~ArrayOfOneDTables()
Destructor.
ArrayOfOneDTables(const char *prefix, const VectorSpace< V, M > &rowSpace)
Default constructor.
void print(std::ostream &os) const
Prints the values in this array of tables.