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,2014, 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 #if VSMC_HAS_CXX11LIB_TUPLE
39 #include <tuple>
40 #endif
41 
42 namespace vsmc {
43 
44 namespace internal {
45 
46 template <MatrixOrder>
47 inline void hdf5io_matrix_dim (std::size_t, std::size_t, ::hsize_t *);
48 
49 template <>
50 inline void hdf5io_matrix_dim<RowMajor> (std::size_t nrow, std::size_t ncol,
51  ::hsize_t *dim)
52 {
53  dim[0] = nrow;
54  dim[1] = ncol;
55 }
56 
57 template <>
58 inline void hdf5io_matrix_dim<ColMajor> (std::size_t nrow, std::size_t ncol,
59  ::hsize_t *dim)
60 {
61  dim[0] = ncol;
62  dim[1] = nrow;
63 }
64 
65 template <typename T>
67 {
69 
70  template <typename OutputIter>
71  void set (std::size_t n, OutputIter) {data_.resize(n);}
72 
73  void set (std::size_t, T *ptr) {ptr_ = ptr;}
74 
75  bool set_ptr () const {return ptr_ == VSMC_NULLPTR;}
76 
77  T *get () {return ptr_ == VSMC_NULLPTR ? &data_[0] : ptr_;}
78 
79  private :
80 
81  T *ptr_;
82  std::vector<T> data_;
83 }; // struct HDF5LoadDataPtr
84 
85 template <typename T>
87 {
89 
90  template <typename InputIter>
91  InputIter set (std::size_t n, InputIter first)
92  {
93  data_.resize(n);
94  T *dst = &data_[0];
95  for (std::size_t i = 0; i != n; ++i, ++first)
96  dst[i] = *first;
97 
98  return first;
99  }
100 
101  T *set (std::size_t n, T *ptr) {ptr_ = ptr; return ptr + n;}
102 
103  const T *set (std::size_t n, const T *ptr) {ptr_ = ptr; return ptr + n;}
104 
105  bool set_ptr () const {return ptr_ == VSMC_NULLPTR;}
106 
107  const T *get () const {return ptr_ == VSMC_NULLPTR ? &data_[0] : ptr_;}
108 
109  private :
110 
111  const T *ptr_;
112  std::vector<T> data_;
113 }; // struct HDF5StoreDataPtr
114 
115 } // namespace vsmc::internal
116 
119 template <typename> inline ::hid_t hdf5io_datatype () {return -1;}
120 
123 template <>
124 inline ::hid_t hdf5io_datatype<char> ()
125 {return ::H5Tcopy(H5T_NATIVE_CHAR);}
126 
129 template <>
131 {return ::H5Tcopy(H5T_NATIVE_SCHAR);}
132 
135 template <>
137 {return ::H5Tcopy(H5T_NATIVE_UCHAR);}
138 
141 template <>
142 inline ::hid_t hdf5io_datatype<short> ()
143 {return ::H5Tcopy(H5T_NATIVE_SHORT);}
144 
147 template <>
149 {return ::H5Tcopy(H5T_NATIVE_UCHAR);}
150 
153 template <>
154 inline ::hid_t hdf5io_datatype<int> ()
155 {return ::H5Tcopy(H5T_NATIVE_INT);}
156 
159 template <>
161 {return ::H5Tcopy(H5T_NATIVE_UINT);}
162 
165 template <>
166 inline ::hid_t hdf5io_datatype<long> ()
167 {return ::H5Tcopy(H5T_NATIVE_LONG);}
168 
171 template <>
173 {return ::H5Tcopy(H5T_NATIVE_ULONG);}
174 
175 #if VSMC_HAS_CXX11_LONG_LONG
176 
179 template <>
180 inline ::hid_t hdf5io_datatype<long long> ()
181 {return ::H5Tcopy(H5T_NATIVE_LLONG);}
182 
185 template <>
187 {return ::H5Tcopy(H5T_NATIVE_ULLONG);}
188 
189 #endif // VSMC_HAS_CXX11_LONG_LONG
190 
193 template <>
194 inline ::hid_t hdf5io_datatype<float> ()
195 {return ::H5Tcopy(H5T_NATIVE_FLOAT);}
196 
199 template <>
200 inline ::hid_t hdf5io_datatype<double> ()
201 {return ::H5Tcopy(H5T_NATIVE_DOUBLE);}
202 
205 template <>
207 {return ::H5Tcopy(H5T_NATIVE_LDOUBLE);}
208 
211 template <typename T>
212 inline ::hsize_t hdf5size (const std::string &file_name,
213  const std::string &data_name)
214 {
215  ::hid_t datafile = ::H5Fopen(file_name.c_str(),
216  H5F_ACC_RDONLY, H5P_DEFAULT);
217  ::hid_t dataset = ::H5Dopen(datafile, data_name.c_str(), H5P_DEFAULT);
218  ::hid_t dataspace = ::H5Dget_space(dataset);
219  ::hid_t datatype = ::H5Dget_type(dataset);
220  std::size_t n = static_cast<std::size_t>(H5Sget_simple_extent_npoints(
221  dataspace));
222  std::size_t b = H5Tget_size(datatype);
223  std::size_t bytes = n * b;
224 
225  ::H5Tclose(datatype);
226  ::H5Sclose(dataspace);
227  ::H5Dclose(dataset);
228  ::H5Fclose(datafile);
229 
230  return bytes / sizeof(T);
231 }
232 
235 template <typename T, typename OutputIter>
236 inline OutputIter hdf5load (const std::string &file_name,
237  const std::string &data_name, OutputIter first)
238 {
239  std::size_t n = hdf5size<T>(file_name, data_name);
241  data_ptr.set(n, first);
242  T *data = data_ptr.get();
243 
244  ::hid_t datafile = ::H5Fopen(file_name.c_str(),
245  H5F_ACC_RDONLY, H5P_DEFAULT);
246  ::hid_t dataset = ::H5Dopen(datafile, data_name.c_str(), H5P_DEFAULT);
247  ::hid_t datatype = ::H5Dget_type(dataset);
248  ::H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
249  if (data_ptr.set_ptr()) {
250  first += n;
251  } else {
252  for (std::size_t i = 0; i != n; ++i, ++first)
253  *first = data[i];
254  }
255 
256  ::H5Tclose(datatype);
257  ::H5Dclose(dataset);
258  ::H5Fclose(datafile);
259 
260  return first;
261 }
262 
312 template <MatrixOrder Order, typename T, typename InputIter>
313 inline InputIter hdf5store_matrix (std::size_t nrow, std::size_t ncol,
314  const std::string &file_name, const std::string &data_name,
315  InputIter first, bool append = false)
316 {
317  if (nrow == 0 || ncol == 0)
318  return first;
319 
320  std::string dataset_name("/" + data_name);
321  ::hsize_t dim[2];
322  internal::hdf5io_matrix_dim<Order>(nrow, ncol, dim);
324  InputIter last = data_ptr.set(nrow * ncol, first);
325  const T *data = data_ptr.get();
326 
327  ::hid_t datafile;
328  if (append) {
329  datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
330  } else {
331  datafile = ::H5Fcreate(file_name.c_str(),
332  H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
333  }
334  ::hid_t dataspace = ::H5Screate_simple(2, dim, VSMC_NULLPTR);
335  ::hid_t datatype = hdf5io_datatype<T>();
336  ::hid_t dataset = ::H5Dcreate(datafile, dataset_name.c_str(),
337  datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
338  ::H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
339 
340  ::H5Dclose(dataset);
341  ::H5Tclose(datatype);
342  ::H5Sclose(dataspace);
343  ::H5Fclose(datafile);
344 
345  return last;
346 }
347 
355 inline void hdf5store_list_empty (const std::string &file_name,
356  const std::string &data_name, bool append)
357 {
358  std::string group_name("/" + data_name);
359 
360  ::hid_t datafile;
361  if (append) {
362  datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
363  } else {
364  datafile = ::H5Fcreate(file_name.c_str(),
365  H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
366  }
367  ::hid_t datagroup = ::H5Gcreate(datafile, group_name.c_str(),
368  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
369  ::H5Gclose(datagroup);
370  ::H5Fclose(datafile);
371 }
372 
398 template <typename T, typename InputIterIter, typename SInputIter>
399 inline void hdf5store_list (std::size_t nrow, std::size_t ncol,
400  const std::string &file_name, const std::string &data_name,
401  InputIterIter first, SInputIter sfirst, bool append = false)
402 {
403  std::string group_name("/" + data_name);
404  ::hsize_t dim[1] = {nrow};
405 
406  ::hid_t datafile;
407  if (append) {
408  datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
409  } else {
410  datafile = ::H5Fcreate(file_name.c_str(),
411  H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
412  }
413  ::hid_t datagroup = ::H5Gcreate(datafile, group_name.c_str(),
414  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
415 
416  if (nrow != 0 && ncol != 0) {
417  ::hid_t dataspace = ::H5Screate_simple(1, dim, VSMC_NULLPTR);
418  ::hid_t datatype = hdf5io_datatype<T>();
420  for (std::size_t j = 0; j != ncol; ++j, ++first, ++sfirst) {
421  data_ptr.set(nrow, *first);
422  const T *data = data_ptr.get();
423  std::string dataset_name(group_name + "/" + (*sfirst));
424  ::hid_t dataset = ::H5Dcreate(datafile, dataset_name.c_str(),
425  datatype, dataspace,
426  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
427  ::H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
428  ::H5Dclose(dataset);
429  }
430  ::H5Tclose(datatype);
431  ::H5Sclose(dataspace);
432  }
433 
434  ::H5Gclose(datagroup);
435  ::H5Fclose(datafile);
436 }
437 
447 template <typename T, typename InputIter>
448 inline void hdf5store_list_insert (std::size_t N,
449  const std::string &file_name, const std::string &data_name,
450  InputIter first, const std::string &vname)
451 {
452  if (N == 0)
453  return;
454 
455  std::string dataset_name("/" + data_name + "/" + vname);
456  ::hsize_t dim[1] = {N};
457 
458  ::hid_t datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
459  ::hid_t dataspace = ::H5Screate_simple(1, dim, VSMC_NULLPTR);
460  ::hid_t datatype = hdf5io_datatype<T>();
462  data_ptr.set(N, first);
463  const T *data = data_ptr.get();
464  ::hid_t dataset = ::H5Dcreate(datafile, dataset_name.c_str(),
465  datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
466  ::H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
467 
468  ::H5Dclose(dataset);
469  ::H5Tclose(datatype);
470  ::H5Sclose(dataspace);
471  ::H5Fclose(datafile);
472 }
473 
474 #if VSMC_HAS_CXX11LIB_TUPLE
475 
476 namespace internal {
477 
478 template <typename TupleVectorType>
479 inline void hdf5_tuple_vector_resize (std::size_t n, TupleVectorType &vec,
480  Position<0>)
481 {std::get<0>(vec).resize(n);}
482 
483 template <typename TupleVectorType, std::size_t Pos>
484 inline void hdf5_tuple_vector_resize (std::size_t n, TupleVectorType &vec,
486 {
487  std::get<Pos>(vec).resize(n);
489 }
490 
491 template <typename TupleVectorType, typename InputIter>
492 inline void hdf5_tuple_vector_copy (std::size_t n, TupleVectorType &vec,
493  InputIter first, Position<0>)
494 {
495  typedef typename std::iterator_traits<InputIter>::value_type tuple_type;
496  typedef typename std::tuple_element<0, tuple_type>::type value_type;
497  value_type *dst = &std::get<0>(vec)[0];
498  InputIter ffirst = first;
499  for (std::size_t i = 0; i != n; ++i, ++ffirst)
500  dst[i] = std::get<0>(*ffirst);
501 }
502 
503 template <typename TupleVectorType, typename InputIter, std::size_t Pos>
504 inline void hdf5_tuple_vector_copy (std::size_t n, TupleVectorType &vec,
505  InputIter first, Position<Pos>)
506 {
507  typedef typename std::iterator_traits<InputIter>::value_type tuple_type;
508  typedef typename std::tuple_element<Pos, tuple_type>::type value_type;
509  value_type *dst = &std::get<Pos>(vec)[0];
510  InputIter ffirst = first;
511  for (std::size_t i = 0; i != n; ++i, ++ffirst)
512  dst[i] = std::get<Pos>(*ffirst);
513  hdf5_tuple_vector_copy(n, vec, first, Position<Pos - 1>());
514 }
515 
516 template <typename TupleVectorType, typename TuplePtrType>
518  const TupleVectorType &vec, TuplePtrType &ptr, Position<0>)
519 {std::get<0>(ptr) = &std::get<0>(vec)[0];}
520 
521 template <typename TupleVectorType, typename TuplePtrType, std::size_t Pos>
523  const TupleVectorType &vec, TuplePtrType &ptr, Position<Pos>)
524 {
525  std::get<Pos>(ptr) = &std::get<Pos>(vec)[0];
527 }
528 
529 template <typename InputIter, typename... InputIters>
530 inline void hdf5store_list_insert_tuple (std::size_t nrow,
531  const std::string &file_name, const std::string &data_name,
532  const std::tuple<InputIter, InputIters...> &first,
533  const std::string *sptr, Position<0>)
534 {
535  typedef typename std::tuple_element<
536  0, std::tuple<InputIter, InputIters...> >::type iter_type;
537  typedef typename std::iterator_traits<iter_type>::value_type dtype;
539  data_ptr.set(nrow, std::get<0>(first));
540  const dtype *data = data_ptr.get();
541  hdf5store_list_insert<dtype>(nrow, file_name, data_name, data, *sptr);
542 }
543 
544 template <typename InputIter, typename... InputIters, std::size_t Pos>
545 inline void hdf5store_list_insert_tuple (std::size_t nrow,
546  const std::string &file_name, const std::string &data_name,
547  const std::tuple<InputIter, InputIters...> &first,
548  const std::string *sptr, Position<Pos>)
549 {
550  typedef typename std::tuple_element<
551  Pos, std::tuple<InputIter, InputIters...> >::type iter_type;
552  typedef typename std::iterator_traits<iter_type>::value_type dtype;
554  data_ptr.set(nrow, std::get<Pos>(first));
555  const dtype *data = data_ptr.get();
556  hdf5store_list_insert<dtype>(nrow, file_name, data_name, data, *sptr);
557  hdf5store_list_insert_tuple(nrow, file_name, data_name, first, --sptr,
559 }
560 
561 } // namespace vsmc::internal
562 
580 template <typename SInputIter, typename InputIter, typename... InputIters>
581 inline void hdf5store_list (std::size_t nrow,
582  const std::string &file_name, const std::string &data_name,
583  const std::tuple<InputIter, InputIters...> &first,
584  SInputIter sfirst, bool append = false)
585 {
586  static VSMC_CONSTEXPR const std::size_t dim = sizeof...(InputIters) + 1;
588  vnames.set(dim, sfirst);
589  const std::string *sptr = vnames.get() + dim;
590  hdf5store_list<int>(0, 0, file_name, data_name,
591  static_cast<int **>(VSMC_NULLPTR),
592  static_cast<std::string *>(VSMC_NULLPTR), append);
593  internal::hdf5store_list_insert_tuple(nrow, file_name, data_name, first,
594  --sptr, Position<dim - 1>());
595 }
596 
597 #endif // VSMC_HAS_CXX11LIB_TUPLE
598 
601 template <typename T>
602 inline void hdf5store (const Sampler<T> &sampler,
603  const std::string &file_name, const std::string &data_name,
604  bool append = false)
605 {
606  std::size_t nrow = sampler.iter_size();
607  std::size_t ncol = sampler.summary_header_size();
608 
609  std::vector<std::string> header(ncol);
610  sampler.summary_header(header.begin());
611  std::vector<double> data(nrow * ncol);
612  sampler.template summary_data<ColMajor>(data.begin());
613  std::vector<const double *> data_ptr(ncol);
614  for (std::size_t j = 0; j != ncol; ++j)
615  data_ptr[j] = &data[0] + j * nrow;
616  hdf5store_list<double>(nrow, ncol, file_name, data_name,
617  data_ptr.begin(), header.begin(), append);
618 
619  std::vector<int> resampled(nrow);
620  sampler.read_resampled_history(resampled.begin());
621  hdf5store_list_insert<int>(nrow, file_name, data_name,
622  &resampled[0], "Resampled");
623 }
624 
627 template <MatrixOrder Order, std::size_t Dim, typename T>
628 inline void hdf5store (const StateMatrix<Order, Dim, T> &state,
629  const std::string &file_name, const std::string &data_name,
630  bool append = false)
631 {
632  hdf5store_matrix<Order, T>(state.size(), state.dim(), file_name, data_name,
633  state.data(), append);
634 }
635 
636 #if VSMC_HAS_CXX11LIB_TUPLE
637 
640 template <typename T, typename... Types>
642  const std::string &file_name, const std::string &data_name,
643  bool append = false)
644 {
645  static VSMC_CONSTEXPR const std::size_t dim = sizeof...(Types) + 1;
646  std::vector<std::string> vnames;
647  vnames.reserve(dim);
648  for (std::size_t i = 0; i != dim; ++i) {
649  std::stringstream ss;
650  ss << 'V' << i;
651  vnames.push_back(ss.str());
652  }
653 
654  std::tuple<std::vector<T>, std::vector<Types>...> data_vec;
655  internal::hdf5_tuple_vector_resize(state.size(), data_vec,
656  Position<dim - 1>());
657  internal::hdf5_tuple_vector_copy(state.size(), data_vec, state.data(),
658  Position<dim - 1>());
659 
660  typename std::tuple<const T *, const Types *...> data_ptr;
661  internal::hdf5_tuple_vector_ptr(data_vec, data_ptr, Position<dim - 1>());
662 
663  hdf5store_list(state.size(), file_name, data_name, data_ptr,
664  &vnames[0], append);
665 }
666 
669 template <typename T, typename... Types>
671  const std::string &file_name, const std::string &data_name,
672  bool append = false)
673 {
674  static VSMC_CONSTEXPR const std::size_t dim = sizeof...(Types) + 1;
675  std::vector<std::string> vnames;
676  vnames.reserve(dim);
677  for (std::size_t i = 0; i != dim; ++i) {
678  std::stringstream ss;
679  ss << 'V' << i;
680  vnames.push_back(ss.str());
681  }
682 
683  hdf5store_list(state.size(), file_name, data_name, state.data(),
684  &vnames[0], append);
685 }
686 
687 #endif // VSMC_HAS_CXX11LIB_TUPLE
688 
691 template <MatrixOrder Order, typename T,
692  std::size_t StateSize, typename FPType, typename ID>
693 inline void hdf5store (const StateCL<StateSize, FPType, ID> &state,
694  const std::string &file_name, const std::string &data_name,
695  bool append = false)
696 {
697  std::size_t nrow = state.size();
698  std::size_t ncol = state.state_size() / sizeof(T);
699  std::size_t N = nrow * ncol;
700  std::vector<T> data(N);
701  state.manager().template read_buffer<T>(state.state_buffer().data(), N,
702  &data[0]);
703  hdf5store_matrix<Order, T>(nrow, ncol, file_name, data_name,
704  &data[0], append);
705 }
706 
707 } // namespace vsmc
708 
709 #endif // VSMC_UTILITY_HDF5IO_HPP
Particle::value_type subtype.
void set(std::size_t, T *ptr)
Definition: hdf5io.hpp:73
inline::hid_t hdf5io_datatype< signed char >()
HDF5 data type specialization for signed char.
Definition: hdf5io.hpp:130
Definition: adapter.hpp:37
const CLBuffer< char, ID > & state_buffer() const
The OpenCL buffer that stores the state values.
Definition: backend_cl.hpp:302
state_tuple_base_type::state_tuple_type * data()
void hdf5store_list_empty(const std::string &file_name, const std::string &data_name, bool append)
Create an empty list.
Definition: hdf5io.hpp:355
inline::hid_t hdf5io_datatype< double >()
HDF5 data type specialization for double.
Definition: hdf5io.hpp:200
#define VSMC_CONSTEXPR
constexpr
Definition: defines.hpp:55
std::size_t summary_header_size() const
The size of Sampler summary header.
Definition: sampler.hpp:563
void set(std::size_t n, OutputIter)
Definition: hdf5io.hpp:71
T * set(std::size_t n, T *ptr)
Definition: hdf5io.hpp:101
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:448
inline::hid_t hdf5io_datatype< unsigned char >()
HDF5 data type specialization for unsigned char.
Definition: hdf5io.hpp:136
std::size_t iter_size() const
Number of iterations (including initialization)
Definition: sampler.hpp:214
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:313
void summary_header(OutputIter first) const
Sampler summary header.
Definition: sampler.hpp:583
const T * set(std::size_t n, const T *ptr)
Definition: hdf5io.hpp:103
void hdf5io_matrix_dim< RowMajor >(std::size_t nrow, std::size_t ncol,::hsize_t *dim)
Definition: hdf5io.hpp:50
inline::hid_t hdf5io_datatype< char >()
HDF5 data type specialization for char.
Definition: hdf5io.hpp:124
Function template argument used for position.
Definition: defines.hpp:126
inline::hid_t hdf5io_datatype< unsigned int >()
HDF5 data type specialization for unsigned int.
Definition: hdf5io.hpp:160
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:212
InputIter set(std::size_t n, InputIter first)
Definition: hdf5io.hpp:91
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:148
void hdf5io_matrix_dim< ColMajor >(std::size_t nrow, std::size_t ncol,::hsize_t *dim)
Definition: hdf5io.hpp:58
inline::hid_t hdf5io_datatype< int >()
HDF5 data type specialization for int.
Definition: hdf5io.hpp:154
size_type size() const
Definition: backend_cl.hpp:274
const ::cl::Buffer & data() const
Read only access to the raw cl::Buffer object.
Definition: cl_buffer.hpp:141
void read_resampled_history(OutputIter first) const
Read resampling indicator history through an output iterator.
Definition: sampler.hpp:296
size_type size() const
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:399
inline::hid_t hdf5io_datatype< long >()
HDF5 data type specialization for long.
Definition: hdf5io.hpp:166
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, Position< 0 >)
Definition: hdf5io.hpp:530
#define VSMC_NULLPTR
nullptr
Definition: defines.hpp:79
MatrixOrder
Matrix order.
Definition: defines.hpp:102
state_tuple_base_type::template state_type< Pos >::type * data(Position< Pos >)
Particle::value_type subtype.
inline::hid_t hdf5io_datatype< unsigned long >()
HDF5 data type specialization for unsigned long.
Definition: hdf5io.hpp:172
void hdf5_tuple_vector_copy(std::size_t n, TupleVectorType &vec, InputIter first, Position< 0 >)
Definition: hdf5io.hpp:492
void hdf5_tuple_vector_ptr(const TupleVectorType &vec, TuplePtrType &ptr, Position< 0 >)
Definition: hdf5io.hpp:517
OutputIter hdf5load(const std::string &file_name, const std::string &data_name, OutputIter first)
Load raw data in the HDF5 format.
Definition: hdf5io.hpp:236
const T * get() const
Definition: hdf5io.hpp:107
inline::hid_t hdf5io_datatype< short >()
HDF5 data type specialization for short.
Definition: hdf5io.hpp:142
inline::hid_t hdf5io_datatype< float >()
HDF5 data type specialization for float.
Definition: hdf5io.hpp:194
SMC Sampler.
Definition: sampler.hpp:58
inline::hid_t hdf5io_datatype< long double >()
HDF5 data type specialization for long double.
Definition: hdf5io.hpp:206
Particle::value_type subtype using OpenCL.
Definition: forward.hpp:76
void hdf5_tuple_vector_resize(std::size_t n, TupleVectorType &vec, Position< 0 >)
Definition: hdf5io.hpp:479
::hid_t hdf5io_datatype()
HDF5 data type.
Definition: hdf5io.hpp:119
inline::hid_t hdf5io_datatype< unsigned long long >()
HDF5 data type specialization for unsigned long.
Definition: hdf5io.hpp:186
inline::hid_t hdf5io_datatype< long long >()
HDF5 data type specialization for long long.
Definition: hdf5io.hpp:180
static manager_type & manager()
The instance of the CLManager signleton associated with this value collcection.
Definition: backend_cl.hpp:299
std::size_t state_size() const
Definition: backend_cl.hpp:276
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:602