vSMC  v3.0.0
Scalable Monte Carlo
Functions
HDF5 objects I/O

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

Functions

template<typename >
inline::hid_t vsmc::hdf5_datatype ()
 HDF5 data type. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< char > ()
 HDF5 data type specialization for char. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< double > ()
 HDF5 data type specialization for double. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< float > ()
 HDF5 data type specialization for float. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< int > ()
 HDF5 data type specialization for int. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< long > ()
 HDF5 data type specialization for long. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< long double > ()
 HDF5 data type specialization for long double. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< long long > ()
 HDF5 data type specialization for long long. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< short > ()
 HDF5 data type specialization for short. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< signed char > ()
 HDF5 data type specialization for signed char. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< unsigned char > ()
 HDF5 data type specialization for unsigned char. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< unsigned int > ()
 HDF5 data type specialization for unsigned int. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< unsigned long > ()
 HDF5 data type specialization for unsigned long. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< unsigned long long > ()
 HDF5 data type specialization for unsigned long. More...
 
template<>
inline::hid_t vsmc::hdf5_datatype< unsigned short > ()
 HDF5 data type specialization for unsigned short. More...
 
template<typename OutputIter >
OutputIter vsmc::hdf5load (const std::string &filename, const std::string &dataname, OutputIter first)
 Load HDF5 data. More...
 
std::size_t vsmc::hdf5load_size (const std::string &filename, const std::string &dataname)
 The number of elements in HDF5 data. More...
 
void vsmc::hdf5store (const std::string &filename)
 Create a new HDF5 file. More...
 
void vsmc::hdf5store (const std::string &filename, const std::string dataname, bool append)
 Create a new HDF5 group. More...
 
template<typename InputIter >
void vsmc::hdf5store (std::size_t N, InputIter first, const std::string &filename, const std::string &dataname, bool append)
 Store one dimensional vector. More...
 
template<typename T , typename Alloc >
void vsmc::hdf5store (const std::vector< T, Alloc > &vector, const std::string &filename, const std::string &dataname, bool append)
 Store one dimensional vector. More...
 
template<typename InputIter >
void vsmc::hdf5store (MatrixLayout layout, std::size_t nrow, std::size_t ncol, InputIter first, const std::string &filename, const std::string &dataname, bool append)
 Store a matrix in the HDF5 format from an input iterator. More...
 
template<MatrixLayout Layout, std::size_t Dim, typename T >
void vsmc::hdf5store (const StateMatrix< Layout, Dim, T > &state_matrix, const std::string &filename, const std::string &dataname, bool append)
 Store a StateMatrix in the HDF5 format. More...
 
template<typename T >
void vsmc::hdf5store (const Particle< T > &particle, const std::string &filename, const std::string &dataname, bool append)
 Store a Particle in the HDF5 format. More...
 
template<typename T >
void vsmc::hdf5store (const Monitor< T > &monitor, const std::string &filename, const std::string &dataname, bool append)
 Store a Monitor in the HDF5 format. More...
 
template<typename T >
void vsmc::hdf5store (const Sampler< T > &sampler, const std::string &filename, const std::string &dataname, bool append)
 Store a Sampler in the HDF5 format. More...
 

Detailed Description

Load and store objects in the HDF5 format.

Function Documentation

template<typename >
inline ::hid_t vsmc::hdf5_datatype ( )

HDF5 data type.

Definition at line 195 of file hdf5.hpp.

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

HDF5 data type specialization for char.

Definition at line 203 of file hdf5.hpp.

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

HDF5 data type specialization for double.

Definition at line 299 of file hdf5.hpp.

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

HDF5 data type specialization for float.

Definition at line 291 of file hdf5.hpp.

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

HDF5 data type specialization for int.

Definition at line 243 of file hdf5.hpp.

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

HDF5 data type specialization for long.

Definition at line 259 of file hdf5.hpp.

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

HDF5 data type specialization for long double.

Definition at line 307 of file hdf5.hpp.

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

HDF5 data type specialization for long long.

Definition at line 275 of file hdf5.hpp.

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

HDF5 data type specialization for short.

Definition at line 227 of file hdf5.hpp.

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

HDF5 data type specialization for signed char.

Definition at line 211 of file hdf5.hpp.

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

HDF5 data type specialization for unsigned char.

Definition at line 219 of file hdf5.hpp.

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

HDF5 data type specialization for unsigned int.

Definition at line 251 of file hdf5.hpp.

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

HDF5 data type specialization for unsigned long.

Definition at line 267 of file hdf5.hpp.

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

HDF5 data type specialization for unsigned long.

Definition at line 283 of file hdf5.hpp.

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

HDF5 data type specialization for unsigned short.

Definition at line 235 of file hdf5.hpp.

template<typename OutputIter >
OutputIter vsmc::hdf5load ( const std::string &  filename,
const std::string &  dataname,
OutputIter  first 
)
inline

Load HDF5 data.

Definition at line 340 of file hdf5.hpp.

std::size_t vsmc::hdf5load_size ( const std::string &  filename,
const std::string &  dataname 
)
inline

The number of elements in HDF5 data.

Definition at line 314 of file hdf5.hpp.

void vsmc::hdf5store ( const std::string &  filename)
inline

Create a new HDF5 file.

Definition at line 408 of file hdf5.hpp.

void vsmc::hdf5store ( const std::string &  filename,
const std::string  dataname,
bool  append 
)
inline

Create a new HDF5 group.

Definition at line 416 of file hdf5.hpp.

template<typename InputIter >
void vsmc::hdf5store ( std::size_t  N,
InputIter  first,
const std::string &  filename,
const std::string &  dataname,
bool  append 
)
inline

Store one dimensional vector.

Definition at line 430 of file hdf5.hpp.

template<typename T , typename Alloc >
void vsmc::hdf5store ( const std::vector< T, Alloc > &  vector,
const std::string &  filename,
const std::string &  dataname,
bool  append 
)
inline

Store one dimensional vector.

Definition at line 465 of file hdf5.hpp.

template<typename InputIter >
void vsmc::hdf5store ( MatrixLayout  layout,
std::size_t  nrow,
std::size_t  ncol,
InputIter  first,
const std::string &  filename,
const std::string &  dataname,
bool  append 
)
inline

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

Note
HDF5 store data in row major layout. For example,
double data[6] = {1, 2, 3, 4, 5, 6};
// Store matrix
// 1 2
// 3 4
// 5 6
hdf5store_matrix<double>(RowMajor, 3, 2, data, "row.hdf5", "data");
// Store matrix
// 1 4
// 2 5
// 3 6
hdf5store_matrix<double>(ColMajor, 3, 2, data, "col.hdf5", "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 layout 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 514 of file hdf5.hpp.

template<MatrixLayout Layout, std::size_t Dim, typename T >
void vsmc::hdf5store ( const StateMatrix< Layout, Dim, T > &  state_matrix,
const std::string &  filename,
const std::string &  dataname,
bool  append 
)
inline

Store a StateMatrix in the HDF5 format.

Definition at line 551 of file hdf5.hpp.

template<typename T >
void vsmc::hdf5store ( const Particle< T > &  particle,
const std::string &  filename,
const std::string &  dataname,
bool  append 
)
inline

Store a Particle in the HDF5 format.

Definition at line 561 of file hdf5.hpp.

template<typename T >
void vsmc::hdf5store ( const Monitor< T > &  monitor,
const std::string &  filename,
const std::string &  dataname,
bool  append 
)
inline

Store a Monitor in the HDF5 format.

Definition at line 573 of file hdf5.hpp.

template<typename T >
void vsmc::hdf5store ( const Sampler< T > &  sampler,
const std::string &  filename,
const std::string &  dataname,
bool  append 
)
inline

Store a Sampler in the HDF5 format.

Definition at line 585 of file hdf5.hpp.