vSMC
vSMC: Scalable Monte Carlo
Functions
HDF5 objects IO

Load and store objects in the HDF5 format. More...

Functions

template<>
inline::hid_t vsmc::hdf5io_datatype< char > ()
 HDF5 data type specialization for char. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< double > ()
 HDF5 data type specialization for double. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< float > ()
 HDF5 data type specialization for float. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< int > ()
 HDF5 data type specialization for int. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< long > ()
 HDF5 data type specialization for long. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< long double > ()
 HDF5 data type specialization for long double. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< long long > ()
 HDF5 data type specialization for long long. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< short > ()
 HDF5 data type specialization for short. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< signed char > ()
 HDF5 data type specialization for signed char. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< unsigned char > ()
 HDF5 data type specialization for unsigned char. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< unsigned int > ()
 HDF5 data type specialization for unsigned int. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< unsigned long > ()
 HDF5 data type specialization for unsigned long. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< unsigned long long > ()
 HDF5 data type specialization for unsigned long. More...
 
template<>
inline::hid_t vsmc::hdf5io_datatype< unsigned short > ()
 HDF5 data type specialization for unsigned short. More...
 
template<typename T , typename OutputIter >
OutputIter vsmc::hdf5load (const std::string &file_name, const std::string &data_name, OutputIter first)
 Load raw data in the HDF5 format. More...
 
inline::hsize_t vsmc::hdf5size (const std::string &file_name, const std::string &data_name)
 Get the number of bytes of the data in the HDF5 format. More...
 
template<typename T >
void vsmc::hdf5store (const Sampler< T > &sampler, const std::string &file_name, const std::string &data_name, bool append=false)
 Store a Sampler in the HDF5 format. More...
 
template<MatrixOrder Order, std::size_t Dim, typename T >
void vsmc::hdf5store (const StateMatrix< Order, Dim, T > &state, const std::string &file_name, const std::string &data_name, bool append=false)
 Store a StateMatrix in the HDF5 format. More...
 
template<MatrixOrder Order, typename T , std::size_t StateSize, typename RealType , typename ID >
void vsmc::hdf5store (const StateCL< StateSize, RealType, ID > &state, const std::string &file_name, const std::string &data_name, bool append=false)
 Store a StateCL in the HDF5 format. More...
 
template<typename T >
void vsmc::hdf5store (const Particle< T > &particle, const std::string &file_name, const std::string &data_name, bool append=false)
 Store a Particle in the HDF5 format. More...
 
template<MatrixOrder Order, typename T , typename U >
void vsmc::hdf5store (const Particle< U > &particle, const std::string &file_name, const std::string &data_name, bool append=false)
 Store a Particle with StateCL value type in the HDF5 format. More...
 
template<typename T , typename InputIterIter , typename SInputIter >
void vsmc::hdf5store_list (std::size_t nrow, std::size_t ncol, const std::string &file_name, const std::string &data_name, InputIterIter first, SInputIter sfirst, bool append=false)
 Store a list in the HDF5 format from an iterator to iterators. More...
 
template<typename SInputIter , typename InputIter , typename... InputIters>
void vsmc::hdf5store_list (std::size_t nrow, const std::string &file_name, const std::string &data_name, const std::tuple< InputIter, InputIters... > &first, SInputIter sfirst, bool append=false)
 Store a list in the HDF5 format from tuple of iterators. More...
 
void vsmc::hdf5store_list_empty (const std::string &file_name, const std::string &data_name, bool append=false)
 Create an empty list. More...
 
template<typename T , typename InputIter >
void vsmc::hdf5store_list_insert (std::size_t N, const std::string &file_name, const std::string &data_name, InputIter first, const std::string &vname)
 Insert a variable into an existing list saved in HDF5 format. More...
 
template<MatrixOrder Order, typename T , typename InputIter >
InputIter vsmc::hdf5store_matrix (std::size_t nrow, std::size_t ncol, const std::string &file_name, const std::string &data_name, InputIter first, bool append=false)
 Store a matrix in the HDF5 format from an input iterator. More...
 
void vsmc::hdf5store_new (const std::string &file_name)
 Create a new HDF5 file for store data. More...
 

Detailed Description

Load and store objects in the HDF5 format.

Function Documentation

template<>
inline ::hid_t vsmc::hdf5io_datatype< char > ( )

HDF5 data type specialization for char.

Definition at line 137 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< double > ( )

HDF5 data type specialization for double.

Definition at line 233 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< float > ( )

HDF5 data type specialization for float.

Definition at line 225 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< int > ( )

HDF5 data type specialization for int.

Definition at line 177 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< long > ( )

HDF5 data type specialization for long.

Definition at line 193 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< long double > ( )

HDF5 data type specialization for long double.

Definition at line 241 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< long long > ( )

HDF5 data type specialization for long long.

Definition at line 209 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< short > ( )

HDF5 data type specialization for short.

Definition at line 161 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< signed char > ( )

HDF5 data type specialization for signed char.

Definition at line 145 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< unsigned char > ( )

HDF5 data type specialization for unsigned char.

Definition at line 153 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< unsigned int > ( )

HDF5 data type specialization for unsigned int.

Definition at line 185 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< unsigned long > ( )

HDF5 data type specialization for unsigned long.

Definition at line 201 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< unsigned long long > ( )

HDF5 data type specialization for unsigned long.

Definition at line 217 of file hdf5io.hpp.

template<>
inline ::hid_t vsmc::hdf5io_datatype< unsigned short > ( )

HDF5 data type specialization for unsigned short.

Definition at line 169 of file hdf5io.hpp.

template<typename T , typename OutputIter >
OutputIter vsmc::hdf5load ( const std::string &  file_name,
const std::string &  data_name,
OutputIter  first 
)
inline

Load raw data in the HDF5 format.

Definition at line 281 of file hdf5io.hpp.

hsize_t vsmc::hdf5size ( const std::string &  file_name,
const std::string &  data_name 
)
inline

Get the number of bytes of the data in the HDF5 format.

Get the number of elements of the data in the HDF5 format given type.

Definition at line 248 of file hdf5io.hpp.

template<typename T >
void vsmc::hdf5store ( const Sampler< T > &  sampler,
const std::string &  file_name,
const std::string &  data_name,
bool  append = false 
)
inline

Store a Sampler in the HDF5 format.

Definition at line 648 of file hdf5io.hpp.

template<MatrixOrder Order, std::size_t Dim, typename T >
void vsmc::hdf5store ( const StateMatrix< Order, Dim, T > &  state,
const std::string &  file_name,
const std::string &  data_name,
bool  append = false 
)
inline

Store a StateMatrix in the HDF5 format.

Definition at line 701 of file hdf5io.hpp.

template<MatrixOrder Order, typename T , std::size_t StateSize, typename RealType , typename ID >
void vsmc::hdf5store ( const StateCL< StateSize, RealType, ID > &  state,
const std::string &  file_name,
const std::string &  data_name,
bool  append = false 
)
inline

Store a StateCL in the HDF5 format.

Definition at line 713 of file hdf5io.hpp.

template<typename T >
void vsmc::hdf5store ( const Particle< T > &  particle,
const std::string &  file_name,
const std::string &  data_name,
bool  append = false 
)
inline

Store a Particle in the HDF5 format.

Definition at line 730 of file hdf5io.hpp.

template<MatrixOrder Order, typename T , typename U >
void vsmc::hdf5store ( const Particle< U > &  particle,
const std::string &  file_name,
const std::string &  data_name,
bool  append = false 
)
inline

Store a Particle with StateCL value type in the HDF5 format.

Definition at line 743 of file hdf5io.hpp.

template<typename T , typename InputIterIter , typename SInputIter >
void vsmc::hdf5store_list ( std::size_t  nrow,
std::size_t  ncol,
const std::string &  file_name,
const std::string &  data_name,
InputIterIter  first,
SInputIter  sfirst,
bool  append = false 
)
inline

Store a list in the HDF5 format from an iterator to iterators.

Template Parameters
TType of the data
InputIterIterThe input iterator type, which points to input iterators
SInputIterThe input iterator type of names
Parameters
nrowNumber of elements in each element of the list
ncolNumber of elements in the list
file_nameName of the HDF5 file
data_nameName of the list
firstAn iterator points to a sequence of iterators of length ncol. Each derefence of an iterator is iteself an iterator that points to the beginning of an element of the list.
sfirstAn iterator points to the beginning of a sequence of strings that store the names of each column. The dereference need to be convertible to std::string
appendIf true the data is appended into an existing file, otherwise save in a new file
Note
Each element in the list is assumed to be a vector of the same length. If the list contains elements of different length, then create an empty list, which is exactly an empty group in HDF5 terminology and use hdf5store_list_insert to insert each element.

Definition at line 458 of file hdf5io.hpp.

template<typename SInputIter , typename InputIter , typename... InputIters>
void vsmc::hdf5store_list ( std::size_t  nrow,
const std::string &  file_name,
const std::string &  data_name,
const std::tuple< InputIter, InputIters... > &  first,
SInputIter  sfirst,
bool  append = false 
)
inline

Store a list in the HDF5 format from tuple of iterators.

A list is similar to that in R. It is much like a matrix except that each column will be stored seperatedly as an variable and given a name.

Parameters
nrowNumber of rows
file_nameName of the HDF5 file
data_nameName of the list
firstA std::tuple type object whose element types are iterators. Each element is the beginning of an element of the list.
sfirstAn iterator points to the beginning of a sequence of strings that store the names of each column. The dereference need to be convertible to std::string
appendIf true the data is appended into an existing file, otherwise save in a new file

Definition at line 588 of file hdf5io.hpp.

void vsmc::hdf5store_list_empty ( const std::string &  file_name,
const std::string &  data_name,
bool  append = false 
)
inline

Create an empty list.

Parameters
file_nameName of the HDF5 file
data_nameName of the list
appendIf true the data is appended into an existing file, otherwise save in a new file

Definition at line 412 of file hdf5io.hpp.

template<typename T , typename InputIter >
void vsmc::hdf5store_list_insert ( std::size_t  N,
const std::string &  file_name,
const std::string &  data_name,
InputIter  first,
const std::string &  vname 
)
inline

Insert a variable into an existing list saved in HDF5 format.

Parameters
NThe length of the variable vector. It may be different from that of the existing list.
file_nameName of the HDF5 file
data_nameName of the list
firstAn iterator points to the beginning of the variable vector
vnameName of the new variable

Definition at line 506 of file hdf5io.hpp.

template<MatrixOrder Order, typename T , typename InputIter >
InputIter vsmc::hdf5store_matrix ( std::size_t  nrow,
std::size_t  ncol,
const std::string &  file_name,
const std::string &  data_name,
InputIter  first,
bool  append = false 
)
inline

Store a matrix in the HDF5 format from an input iterator.

Template Parameters
OrderStorage order (RowMajor or ColMajor)
TType of the data
Parameters
nrowNumber of rows
ncolNumber of columns
file_nameName of the HDF5 file
data_nameName of the matrix data
firstAn input iterator to sequence of length nrow * ncol
appendIf true the data is appended into an existing file, otherwise save in a new file
Note
HDF5 store data in row major order. For example,
double data[6] = {1, 2, 3, 4, 5, 6};
// Store matrix
// 1 2
// 3 4
// 5 6
hdf5store_matrix<RowMajor, double>(3, 2, "row.hdf5", "data", data);
// Store matrix
// 1 4
// 2 5
// 3 6
hdf5store_matrix<ColMajor, double>(3, 2, "col.hdf5", "data", data);
When the results are read by other program, for example R, a transpose may be needed. For instance,
1 library(rhdf5)
2 row <- h5read("row.hdf5", "/data")
3 print(row) # produce
4 # [,1] [,2] [,3]
5 # [1,] 1 3 5
6 # [2,] 2 4 6
7 col <- h5read("col.hdf5", "/data")
8 print(col) # produce
9 # [,1] [,2]
10 # [1,] 1 4
11 # [2,] 2 5
12 # [3,] 3 6
13 #
That is, when the data is stored in column major order in C++ memory, then the read in R produces exactly the same output. If the data is stored as row major matrix in C++ memory, the read in R produces the transpose the original matrix though they are identical in memory.

Definition at line 369 of file hdf5io.hpp.

void vsmc::hdf5store_new ( const std::string &  file_name)
inline

Create a new HDF5 file for store data.

Definition at line 310 of file hdf5io.hpp.