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 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>&
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)
void setOneDTable(unsigned int rowId, const std::vector< double > &values)
Sets the one-dimensional table.
void print(std::ostream &os) const
Prints the values in this array of tables.
int MyLength() const
Returns the length of the locally owned array.
#define queso_require_msg(asserted, msg)
#define queso_require_less_msg(expr1, expr2, msg)
DistArray< std::vector< double > * > m_oneDTables
ArrayOfOneDTables(const char *prefix, const VectorSpace< V, M > &rowSpace)
Default constructor.
Class to accommodate arrays of one-dimensional tables.
const std::vector< double > & oneDTable(unsigned int rowId) const
Returns the array located at position rowId of the one-dimensional table.
A class representing a vector space.
~ArrayOfOneDTables()
Destructor.