vSMC
vSMC: Scalable Monte Carlo
hdf5io.hpp
Go to the documentation of this file.
1 //============================================================================
2 // vSMC/include/vsmc/utility/hdf5io.hpp
3 //----------------------------------------------------------------------------
4 // vSMC: Scalable Monte Carlo
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2016, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef VSMC_UTILITY_HDF5IO_HPP
33 #define VSMC_UTILITY_HDF5IO_HPP
34 
35 #include <vsmc/internal/common.hpp>
36 #include <hdf5.h>
37 
38 namespace vsmc
39 {
40 
41 namespace internal
42 {
43 
44 template <MatrixLayout>
45 inline void hdf5io_matrix_dim(std::size_t, std::size_t, ::hsize_t *);
46 
47 template <>
49  std::size_t nrow, std::size_t ncol, ::hsize_t *dim)
50 {
51  dim[0] = nrow;
52  dim[1] = ncol;
53 }
54 
55 template <>
57  std::size_t nrow, std::size_t ncol, ::hsize_t *dim)
58 {
59  dim[0] = ncol;
60  dim[1] = nrow;
61 }
62 
63 template <typename T>
65 {
66  public:
67  HDF5LoadDataPtr() : ptr_(nullptr) {}
68 
69  template <typename OutputIter>
70  void set(std::size_t n, OutputIter)
71  {
72  data_.resize(n);
73  }
74 
75  void set(std::size_t, T *ptr) { ptr_ = ptr; }
76 
77  T *get() { return ptr_ == nullptr ? data_.data() : ptr_; }
78 
79  bool is_raw_ptr() const { return ptr_ == nullptr; }
80 
81  private:
82  T *ptr_;
83  Vector<T> data_;
84 }; // class HDF5LoadDataPtr
85 
86 template <typename T>
88 {
89  public:
90  HDF5StoreDataPtr() : ptr_(nullptr) {}
91 
92  template <typename InputIter>
93  InputIter set(std::size_t n, InputIter first)
94  {
95  data_.resize(n);
96  T *dst = data_.data();
97  for (std::size_t i = 0; i != n; ++i, ++first)
98  dst[i] = *first;
99 
100  return first;
101  }
102 
103  T *set(std::size_t n, T *ptr)
104  {
105  ptr_ = ptr;
106  return ptr + n;
107  }
108 
109  const T *set(std::size_t n, const T *ptr)
110  {
111  ptr_ = ptr;
112  return ptr + n;
113  }
114 
115  const T *get() const { return ptr_ == nullptr ? data_.data() : ptr_; }
116 
117  bool is_raw_ptr() const { return ptr_ == nullptr; }
118 
119  private:
120  const T *ptr_;
121  Vector<T> data_;
122 }; // class HDF5StoreDataPtr
123 
124 } // namespace vsmc::internal
125 
128 template <typename>
129 inline ::hid_t hdf5io_datatype()
130 {
131  return -1;
132 }
133 
136 template <>
137 inline ::hid_t hdf5io_datatype<char>()
138 {
139  return ::H5Tcopy(H5T_NATIVE_CHAR);
140 }
141 
144 template <>
146 {
147  return ::H5Tcopy(H5T_NATIVE_SCHAR);
148 }
149 
152 template <>
154 {
155  return ::H5Tcopy(H5T_NATIVE_UCHAR);
156 }
157 
160 template <>
161 inline ::hid_t hdf5io_datatype<short>()
162 {
163  return ::H5Tcopy(H5T_NATIVE_SHORT);
164 }
165 
168 template <>
170 {
171  return ::H5Tcopy(H5T_NATIVE_UCHAR);
172 }
173 
176 template <>
177 inline ::hid_t hdf5io_datatype<int>()
178 {
179  return ::H5Tcopy(H5T_NATIVE_INT);
180 }
181 
184 template <>
186 {
187  return ::H5Tcopy(H5T_NATIVE_UINT);
188 }
189 
192 template <>
193 inline ::hid_t hdf5io_datatype<long>()
194 {
195  return ::H5Tcopy(H5T_NATIVE_LONG);
196 }
197 
200 template <>
202 {
203  return ::H5Tcopy(H5T_NATIVE_ULONG);
204 }
205 
208 template <>
210 {
211  return ::H5Tcopy(H5T_NATIVE_LLONG);
212 }
213 
216 template <>
218 {
219  return ::H5Tcopy(H5T_NATIVE_ULLONG);
220 }
221 
224 template <>
225 inline ::hid_t hdf5io_datatype<float>()
226 {
227  return ::H5Tcopy(H5T_NATIVE_FLOAT);
228 }
229 
232 template <>
233 inline ::hid_t hdf5io_datatype<double>()
234 {
235  return ::H5Tcopy(H5T_NATIVE_DOUBLE);
236 }
237 
240 template <>
242 {
243  return ::H5Tcopy(H5T_NATIVE_LDOUBLE);
244 }
245 
248 inline ::hsize_t hdf5size(
249  const std::string &file_name, const std::string &data_name)
250 {
251  ::hid_t datafile =
252  ::H5Fopen(file_name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
253  ::hid_t dataset = ::H5Dopen(datafile, data_name.c_str(), H5P_DEFAULT);
254  ::hid_t dataspace = ::H5Dget_space(dataset);
255  ::hid_t datatype = ::H5Dget_type(dataset);
256  std::size_t n =
257  static_cast<std::size_t>(H5Sget_simple_extent_npoints(dataspace));
258  std::size_t b = H5Tget_size(datatype);
259  std::size_t bytes = n * b;
260 
261  ::H5Tclose(datatype);
262  ::H5Sclose(dataspace);
263  ::H5Dclose(dataset);
264  ::H5Fclose(datafile);
265 
266  return bytes;
267 }
268 
271 template <typename T>
272 inline ::hsize_t hdf5size(
273  const std::string &file_name, const std::string &data_name)
274 {
275  return hdf5size(file_name, data_name) / sizeof(T);
276 }
277 
280 template <typename T, typename OutputIter>
281 inline OutputIter hdf5load(const std::string &file_name,
282  const std::string &data_name, OutputIter first)
283 {
284  std::size_t n = hdf5size(file_name, data_name) / sizeof(T);
286  data_ptr.set(n, first);
287  T *data = data_ptr.get();
288 
289  ::hid_t datafile =
290  ::H5Fopen(file_name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
291  ::hid_t dataset = ::H5Dopen(datafile, data_name.c_str(), H5P_DEFAULT);
292  ::hid_t datatype = ::H5Dget_type(dataset);
293  ::H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
294  if (data_ptr.is_raw_ptr()) {
295  first += n;
296  } else {
297  for (std::size_t i = 0; i != n; ++i, ++first)
298  *first = data[i];
299  }
300 
301  ::H5Tclose(datatype);
302  ::H5Dclose(dataset);
303  ::H5Fclose(datafile);
304 
305  return first;
306 }
307 
310 inline void hdf5store_new(const std::string &file_name)
311 {
312  ::hid_t datafile = ::H5Fcreate(
313  file_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
314  ::H5Fclose(datafile);
315 }
316 
367 template <MatrixLayout Layout, typename T, typename InputIter>
368 inline InputIter hdf5store_matrix(std::size_t nrow, std::size_t ncol,
369  const std::string &file_name, const std::string &data_name,
370  InputIter first, bool append = false)
371 {
372  if (nrow == 0 || ncol == 0)
373  return first;
374 
375  std::string dataset_name("/" + data_name);
376  ::hsize_t dim[2];
377  internal::hdf5io_matrix_dim<Layout>(nrow, ncol, dim);
379  InputIter last = data_ptr.set(nrow * ncol, first);
380  const T *data = data_ptr.get();
381 
382  ::hid_t datafile;
383  if (append) {
384  datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
385  } else {
386  datafile = ::H5Fcreate(
387  file_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
388  }
389  ::hid_t dataspace = ::H5Screate_simple(2, dim, nullptr);
390  ::hid_t datatype = hdf5io_datatype<T>();
391  ::hid_t dataset = ::H5Dcreate(datafile, dataset_name.c_str(), datatype,
392  dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
393  ::H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
394 
395  ::H5Dclose(dataset);
396  ::H5Tclose(datatype);
397  ::H5Sclose(dataspace);
398  ::H5Fclose(datafile);
399 
400  return last;
401 }
402 
411 inline void hdf5store_list_empty(const std::string &file_name,
412  const std::string &data_name, bool append = false)
413 {
414  std::string group_name("/" + data_name);
415 
416  ::hid_t datafile;
417  if (append) {
418  datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
419  } else {
420  datafile = ::H5Fcreate(
421  file_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
422  }
423  ::hid_t datagroup = ::H5Gcreate(
424  datafile, group_name.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
425  ::H5Gclose(datagroup);
426  ::H5Fclose(datafile);
427 }
428 
456 template <typename T, typename InputIterIter, typename SInputIter>
457 inline void hdf5store_list(std::size_t nrow, std::size_t ncol,
458  const std::string &file_name, const std::string &data_name,
459  InputIterIter first, SInputIter sfirst, bool append = false)
460 {
461  std::string group_name("/" + data_name);
462  ::hsize_t dim[1] = {nrow};
463 
464  ::hid_t datafile;
465  if (append) {
466  datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
467  } else {
468  datafile = ::H5Fcreate(
469  file_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
470  }
471  ::hid_t datagroup = ::H5Gcreate(
472  datafile, group_name.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
473 
474  if (nrow != 0 && ncol != 0) {
475  ::hid_t dataspace = ::H5Screate_simple(1, dim, nullptr);
476  ::hid_t datatype = hdf5io_datatype<T>();
478  for (std::size_t j = 0; j != ncol; ++j, ++first, ++sfirst) {
479  data_ptr.set(nrow, *first);
480  const T *data = data_ptr.get();
481  std::string dataset_name(group_name + "/" + (*sfirst));
482  ::hid_t dataset = ::H5Dcreate(datafile, dataset_name.c_str(),
483  datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
484  ::H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
485  ::H5Dclose(dataset);
486  }
487  ::H5Tclose(datatype);
488  ::H5Sclose(dataspace);
489  }
490 
491  ::H5Gclose(datagroup);
492  ::H5Fclose(datafile);
493 }
494 
504 template <typename T, typename InputIter>
505 inline void hdf5store_list_insert(std::size_t N, const std::string &file_name,
506  const std::string &data_name, InputIter first, const std::string &vname)
507 {
508  if (N == 0)
509  return;
510 
511  std::string dataset_name("/" + data_name + "/" + vname);
512  ::hsize_t dim[1] = {N};
513 
514  ::hid_t datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
515  ::hid_t dataspace = ::H5Screate_simple(1, dim, nullptr);
516  ::hid_t datatype = hdf5io_datatype<T>();
518  data_ptr.set(N, first);
519  const T *data = data_ptr.get();
520  ::hid_t dataset = ::H5Dcreate(datafile, dataset_name.c_str(), datatype,
521  dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
522  ::H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
523 
524  ::H5Dclose(dataset);
525  ::H5Tclose(datatype);
526  ::H5Sclose(dataspace);
527  ::H5Fclose(datafile);
528 }
529 
530 namespace internal
531 {
532 
533 template <typename InputIter, typename... InputIters>
534 inline void hdf5store_list_insert_tuple(std::size_t nrow,
535  const std::string &file_name, const std::string &data_name,
536  const std::tuple<InputIter, InputIters...> &first, const std::string *sptr,
537  std::integral_constant<std::size_t, 0>)
538 {
539  using value_type =
540  typename std::iterator_traits<typename std::tuple_element<0,
541  std::tuple<InputIter, InputIters...>>::type>::value_type;
543  data_ptr.set(nrow, std::get<0>(first));
544  const value_type *data = data_ptr.get();
545  hdf5store_list_insert<value_type>(nrow, file_name, data_name, data, *sptr);
546 }
547 
548 template <typename InputIter, typename... InputIters, std::size_t Pos>
549 inline void hdf5store_list_insert_tuple(std::size_t nrow,
550  const std::string &file_name, const std::string &data_name,
551  const std::tuple<InputIter, InputIters...> &first, const std::string *sptr,
552  std::integral_constant<std::size_t, Pos>)
553 {
554  using value_type =
555  typename std::iterator_traits<typename std::tuple_element<Pos,
556  std::tuple<InputIter, InputIters...>>::type>::value_type;
558  data_ptr.set(nrow, std::get<Pos>(first));
559  const value_type *data = data_ptr.get();
560  hdf5store_list_insert<value_type>(nrow, file_name, data_name, data, *sptr);
561  hdf5store_list_insert_tuple(nrow, file_name, data_name, first, --sptr,
562  std::integral_constant<std::size_t, Pos - 1>());
563 }
564 
565 } // namespace vsmc::internal
566 
586 template <typename SInputIter, typename InputIter, typename... InputIters>
587 inline void hdf5store_list(std::size_t nrow, const std::string &file_name,
588  const std::string &data_name,
589  const std::tuple<InputIter, InputIters...> &first, SInputIter sfirst,
590  bool append = false)
591 {
592  static constexpr std::size_t dim = sizeof...(InputIters) + 1;
594  vnames.set(dim, sfirst);
595  const std::string *sptr = vnames.get() + dim;
596  hdf5store_list_empty(file_name, data_name, append);
597  internal::hdf5store_list_insert_tuple(nrow, file_name, data_name, first,
598  --sptr, std::integral_constant<std::size_t, dim - 1>());
599 }
600 
601 namespace internal
602 {
603 
604 template <typename IntType>
605 inline bool hdf5store_int(std::size_t n, IntType *r, std::false_type)
606 {
607  if (sizeof(int) > sizeof(IntType))
608  return true;
609 
610  bool flag = true;
611  for (std::size_t i = 0; i != n; ++i) {
612  if (r[i] > std::numeric_limits<int>::max()) {
613  flag = false;
614  break;
615  }
616  }
617 
618  return flag;
619 }
620 
621 template <typename IntType>
622 inline bool hdf5store_int(std::size_t n, IntType *r, std::true_type)
623 {
624  if (sizeof(int) > sizeof(IntType))
625  return true;
626 
627  bool flag = true;
628  for (std::size_t i = 0; i != n; ++i) {
629  if (r[i] < std::numeric_limits<int>::min()) {
630  flag = false;
631  break;
632  }
633  if (r[i] > std::numeric_limits<int>::max()) {
634  flag = false;
635  break;
636  }
637  }
638 
639  return flag;
640 }
641 
642 } // namespace vsmc::internal
643 
646 template <typename T>
647 inline void hdf5store(const Sampler<T> &sampler, const std::string &file_name,
648  const std::string &data_name, bool append = false)
649 {
650  using size_type = typename Sampler<T>::size_type;
651 
652  std::size_t nrow = sampler.iter_size();
653 
654  if (nrow == 0)
655  return;
656 
657  hdf5store_list_empty(file_name, data_name, append);
658 
659  std::size_t ncol_int = sampler.summary_header_size_int();
660  Vector<std::string> header_int(ncol_int);
661  Vector<size_type> data_int(nrow * ncol_int);
662  sampler.summary_header_int(header_int.begin());
663  sampler.template summary_data_int<ColMajor>(data_int.begin());
664  bool use_int = internal::hdf5store_int(
665  data_int.size(), data_int.data(), std::is_signed<size_type>());
666  if (use_int) {
667  Vector<int> data_int_small(data_int.size());
668  std::copy(data_int.begin(), data_int.end(), data_int_small.begin());
669  Vector<const int *> data_ptr_int(ncol_int);
670  for (std::size_t j = 0; j != ncol_int; ++j)
671  data_ptr_int[j] = data_int_small.data() + j * nrow;
672  for (std::size_t j = 0; j != ncol_int; ++j)
673  hdf5store_list_insert<int>(
674  nrow, file_name, data_name, data_ptr_int[j], header_int[j]);
675  } else {
676  Vector<const size_type *> data_ptr_int(ncol_int);
677  for (std::size_t j = 0; j != ncol_int; ++j)
678  data_ptr_int[j] = data_int.data() + j * nrow;
679  for (std::size_t j = 0; j != ncol_int; ++j)
680  hdf5store_list_insert<size_type>(
681  nrow, file_name, data_name, data_ptr_int[j], header_int[j]);
682  }
683 
684  std::size_t ncol = sampler.summary_header_size();
685  Vector<std::string> header(ncol);
686  Vector<double> data(nrow * ncol);
687  sampler.summary_header(header.begin());
688  sampler.template summary_data<ColMajor>(data.begin());
689  Vector<const double *> data_ptr(ncol);
690  for (std::size_t j = 0; j != ncol; ++j)
691  data_ptr[j] = data.data() + j * nrow;
692  for (std::size_t j = 0; j != ncol; ++j)
693  hdf5store_list_insert<double>(
694  nrow, file_name, data_name, data_ptr[j], header[j]);
695 }
696 
699 template <MatrixLayout Layout, std::size_t Dim, typename T>
700 inline void hdf5store(const StateMatrix<Layout, Dim, T> &state,
701  const std::string &file_name, const std::string &data_name,
702  bool append = false)
703 {
704  hdf5store_matrix<Layout, T>(
705  state.size(), state.dim(), file_name, data_name, state.data(), append);
706 }
707 
710 template <MatrixLayout Layout, typename T, std::size_t StateSize,
711  typename RealType, typename ID>
713  const std::string &file_name, const std::string &data_name,
714  bool append = false)
715 {
716  std::size_t nrow = state.size();
717  std::size_t ncol = state.state_size() / sizeof(T);
718  std::size_t N = nrow * ncol;
719  Vector<T> data(N);
720  state.manager().template read_buffer<T>(
721  state.state_buffer().data(), N, data.data());
722  hdf5store_matrix<Layout, T>(
723  nrow, ncol, file_name, data_name, data.data(), append);
724 }
725 
728 template <typename T>
729 inline void hdf5store(const Particle<T> &particle,
730  const std::string &file_name, const std::string &data_name,
731  bool append = false)
732 {
733  hdf5store_list_empty(file_name, data_name, append);
734  hdf5store(particle.value(), file_name, data_name + "/value", true);
735  hdf5store_matrix<ColMajor, double>(particle.size(), 1, file_name,
736  data_name + "/weight", particle.weight().data(), true);
737 }
738 
741 template <MatrixLayout Layout, typename T, typename U>
742 inline void hdf5store(const Particle<U> &particle,
743  const std::string &file_name, const std::string &data_name,
744  bool append = false)
745 {
746  hdf5store_list_empty(file_name, data_name, append);
747  hdf5store<Layout, T>(
748  particle.value(), file_name, data_name + "/value", true);
749  hdf5store_matrix<ColMajor, double>(particle.size(), 1, file_name,
750  data_name + "/weight", particle.weight().data(), true);
751 }
752 
753 } // namespace vsmc
754 
755 #endif // VSMC_UTILITY_HDF5IO_HPP
inline::hid_t hdf5io_datatype< signed char >()
HDF5 data type specialization for signed char.
Definition: hdf5io.hpp:145
Definition: monitor.hpp:49
Particle class representing the whole particle set.
Definition: particle.hpp:48
typename std::conditional< std::is_scalar< T >::value, AlignedVector< T >, std::vector< T >>::type Vector
AlignedVector for scalar type and std::vector for others.
inline::hid_t hdf5io_datatype< double >()
HDF5 data type specialization for double.
Definition: hdf5io.hpp:233
MatrixLayout
Matrix layout.
Definition: defines.hpp:49
std::size_t summary_header_size() const
The size of Sampler summary header (floating point data)
Definition: sampler.hpp:562
value_type & value()
Read and write access to the value collection object.
Definition: particle.hpp:125
void 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.
Definition: hdf5io.hpp:505
weight_type & weight()
Read and write access to the weight collection object.
Definition: particle.hpp:131
inline::hid_t hdf5io_datatype< unsigned char >()
HDF5 data type specialization for unsigned char.
Definition: hdf5io.hpp:153
std::size_t iter_size() const
Number of iterations (including initialization)
Definition: sampler.hpp:205
InputIter 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.
Definition: hdf5io.hpp:368
void summary_header(OutputIter first) const
Sampler summary header (floating point data)
Definition: sampler.hpp:590
inline::hid_t hdf5io_datatype()
HDF5 data type.
Definition: hdf5io.hpp:129
void hdf5io_matrix_dim< RowMajor >(std::size_t nrow, std::size_t ncol,::hsize_t *dim)
Definition: hdf5io.hpp:48
inline::hid_t hdf5io_datatype< char >()
HDF5 data type specialization for char.
Definition: hdf5io.hpp:137
void summary_header_int(OutputIter first) const
Sampler summary header (integer data)
Definition: sampler.hpp:577
inline::hid_t hdf5io_datatype< unsigned int >()
HDF5 data type specialization for unsigned int.
Definition: hdf5io.hpp:185
void hdf5io_matrix_dim(std::size_t, std::size_t,::hsize_t *)
inline::hid_t hdf5io_datatype< unsigned short >()
HDF5 data type specialization for unsigned short.
Definition: hdf5io.hpp:169
void hdf5io_matrix_dim< ColMajor >(std::size_t nrow, std::size_t ncol,::hsize_t *dim)
Definition: hdf5io.hpp:56
inline::hid_t hdf5io_datatype< int >()
HDF5 data type specialization for int.
Definition: hdf5io.hpp:177
typename Particle< T >::size_type size_type
Definition: sampler.hpp:61
void 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.
Definition: hdf5io.hpp:457
inline::hid_t hdf5io_datatype< long >()
HDF5 data type specialization for long.
Definition: hdf5io.hpp:193
void hdf5store_new(const std::string &file_name)
Create a new HDF5 file for store data.
Definition: hdf5io.hpp:310
inline::hsize_t hdf5size(const std::string &file_name, const std::string &data_name)
Get the number of bytes of the data in the HDF5 format.
Definition: hdf5io.hpp:248
const T * get() const
Definition: hdf5io.hpp:115
void hdf5store_list_insert_tuple(std::size_t nrow, const std::string &file_name, const std::string &data_name, const std::tuple< InputIter, InputIters... > &first, const std::string *sptr, std::integral_constant< std::size_t, 0 >)
Definition: hdf5io.hpp:534
void hdf5store_list_empty(const std::string &file_name, const std::string &data_name, bool append=false)
Create an empty list.
Definition: hdf5io.hpp:411
std::size_t summary_header_size_int() const
The size of Sampler summary header (integer data, size etc.)
Definition: sampler.hpp:553
inline::hid_t hdf5io_datatype< unsigned long >()
HDF5 data type specialization for unsigned long.
Definition: hdf5io.hpp:201
InputIter set(std::size_t n, InputIter first)
Definition: hdf5io.hpp:93
void set(std::size_t n, OutputIter)
Definition: hdf5io.hpp:70
OutputIter hdf5load(const std::string &file_name, const std::string &data_name, OutputIter first)
Load raw data in the HDF5 format.
Definition: hdf5io.hpp:281
inline::hid_t hdf5io_datatype< short >()
HDF5 data type specialization for short.
Definition: hdf5io.hpp:161
inline::hid_t hdf5io_datatype< float >()
HDF5 data type specialization for float.
Definition: hdf5io.hpp:225
size_type size() const
Number of particles.
Definition: particle.hpp:122
SMC Sampler.
Definition: sampler.hpp:58
inline::hid_t hdf5io_datatype< long double >()
HDF5 data type specialization for long double.
Definition: hdf5io.hpp:241
bool hdf5store_int(std::size_t n, IntType *r, std::false_type)
Definition: hdf5io.hpp:605
inline::hid_t hdf5io_datatype< unsigned long long >()
HDF5 data type specialization for unsigned long.
Definition: hdf5io.hpp:217
inline::hid_t hdf5io_datatype< long long >()
HDF5 data type specialization for long long.
Definition: hdf5io.hpp:209
void 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.
Definition: hdf5io.hpp:647