HDF5 Eigen Wrapper

Many of the core HDF5 functionality is contained here. The more complicated details required to read and write Eigen objects happens here and should typically not be utilized directly

Functions

template<typename Derived>
void load(const H5::H5Location &h5group, const std::string &name, const Eigen::DenseBase<Derived> &mat)

This will read from an HDF5 file/group and save the data into an eigen matrix. One should have some idea about the eigen array before reading

Author

Shankar Kulumani

Version

26 April 2018

Parameters
  • h5group: H5 group or file to read from

  • name: String name of the dataset

  • mat: Eigen variable to save data

template<typename Derived>
void save(H5::H5Location &h5group, const std::string &name, const Eigen::EigenBase<Derived> &mat, const H5::DSetCreatPropList &plist = H5::DSetCreatPropList::DEFAULT)

This will write Eigen data to an HDF5 file or group

Author

Shankar Kulumani

Version

26 April 2018

Parameters
  • h5group: The H5 group or file to write to

  • name: string name of the dataset

  • mat: Eigen variable to save data

  • plist: The dataset property list

template<typename T>
class DatatypeSpecialization
#include <hdf5_eigen.hpp>

Convert a C++ datatype to the equivalent in HDF5 land.

All Eigen functionality to read/write to HDF5

Updated/corrected from the work of Jim Garrison https://github.com/garrison/eigen3-hdf5

Each dataset must define the correct type in the

HDF5. This template class handles that by automatially determining the HDF5 type from a Eigen input.
Author

Shankar Kulumani

Version

26 April 2018

Setup primiarly for Eigen types but needs to be extended.

Author

Shankar Kulumani

Version

26 April 2018

template<>
struct DatatypeSpecialization<float>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<double>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<long double>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<short>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<unsigned short>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<int>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<unsigned int>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<long>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<unsigned long>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<long long>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<unsigned long long>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<const char *>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<>
struct DatatypeSpecialization<char *>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<std::size_t N>
struct DatatypeSpecialization<const char[N]>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
template<std::size_t N>
struct DatatypeSpecialization<char[N]>
#include <hdf5_eigen.hpp>

Public Static Functions

static const H5::DataType *get(void)
namespace internal

Functions

template<typename Derived>
H5::DataSpace create_dataspace(const Eigen::EigenBase<Derived> &mat)

Create the dataspace required for the HDF5 dataset

Return

H5::DataSpace Defines the space required to store mat

Author

Shankar Kulumani

Version

26 April 2018

Parameters
  • mat: Eigen matrix to write to the file

template<typename Derived>
bool write_rowmat(const Eigen::EigenBase<Derived> &mat, const H5::DataType *const datatype, H5::DataSet *dataset, const H5::DataSpace *dspace)
template<typename Derived>
bool write_colmat(const Eigen::EigenBase<Derived> &mat, const H5::DataType *const datatype, H5::DataSet *dataset, const H5::DataSpace *dspace)
template<typename Scalar>
void read_data(const H5::DataSet &dataset, Scalar *data, const H5::DataType &datatype)
template<typename Scalar>
void read_data(const H5::Attribute &dataset, Scalar *data, const H5::DataType &datatype)
template<typename Derived>
bool read_colmat(const Eigen::DenseBase<Derived> &mat, const H5::DataType *const datatype, const H5::Attribute &dataset)
template<typename Derived>
bool read_colmat(const Eigen::DenseBase<Derived> &mat, const H5::DataType *const datatype, const H5::DataSet &dataset)
template<typename Derived, typename DataSet>
void _load(const DataSet &dataset, const Eigen::DenseBase<Derived> &mat)