#include <iostream>
#include <dlib/matrix.h>
#include <h5cpp/all>
template <class T> using Matrix = dlib::matrix<T>;
int main() {
auto check = [](const char* label, bool ok) {
std::cout << (ok ?
"✔ ok " :
"✘ failed") <<
" " << label <<
"\n";
};
{
Matrix<double> M(3, 4);
for (long r = 0; r < M.nr(); ++r)
for (long c = 0; c < M.nc(); ++c)
M(r, c) = r * M.nc() + c;
bool shape = (back.nr() == M.nr()) && (back.nc() == M.nc());
bool values = shape;
for (long r = 0; values && r < M.nr(); ++r)
for (long c = 0; values && c < M.nc(); ++c)
values = values && (back(r, c) == M(r, c));
check("dlib::matrix<double>(3x4) shape + values", shape && values);
}
{
Matrix<short> v(5, 1);
v = 0, 1, 2, 3, 4;
bool shape = (back.nr() == v.nr()) && (back.nc() == v.nc());
bool values = shape;
for (long r = 0; values && r < v.nr(); ++r)
values = values && (back(r, 0) == v(r, 0));
check("dlib::matrix<short>(5x1) 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