#include <iostream>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <h5cpp/all>
template <class T> using Matrix = boost::numeric::ublas::matrix<T>;
template <class T> using Vector = boost::numeric::ublas::vector<T>;
int main() {
auto check = [](const char* label, bool ok) {
std::cout << (ok ?
"✔ ok " :
"✘ failed") <<
" " << label <<
"\n";
};
{
Vector<double> v(8);
for (
std::size_t i = 0; i < v.size(); ++i) v(i) = i + 1.0;
bool shape = (back.size() == v.size());
bool values = shape;
values = values && (back(i) == v(i));
check("ublas::vector<double>(8) shape + values", shape && values);
}
{
Matrix<short> M(3, 4);
M(r, c) = static_cast<short>(r * M.size2() + c);
bool shape = (back.size1() == M.size1()) && (back.size2() == M.size2());
bool values = shape;
values = values && (back(r, c) == M(r, c));
check("ublas::matrix<short>(3x4) shape + values", shape && values);
}
return 0;
}
h5::at_t create(const hid_t &parent, const std::string &path, args_t &&... args)
Create a new attribute of element type T on a parent HDF5 object.
Definition H5Acreate.hpp:100
T aread(const hid_t &ds, const std::string &name, const h5::acpl_t &acpl=h5::default_acpl)
Read an attribute by name and return its value as type T.
Definition H5Aread.hpp:76
h5::gr_t write(const LOC &parent, const std::string &path, const T &src)
Write a sparse matrix or vector as a CSC group.
Definition H5Dsparse.hpp:185