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-2015, 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 <MatrixOrder>
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 
368 template <MatrixOrder Order, typename T, typename InputIter>
369 inline InputIter hdf5store_matrix(std::size_t nrow, std::size_t ncol,
370  const std::string &file_name, const std::string &data_name,
371  InputIter first, bool append = false)
372 {
373  if (nrow == 0 || ncol == 0)
374  return first;
375 
376  std::string dataset_name("/" + data_name);
377  ::hsize_t dim[2];
378  internal::hdf5io_matrix_dim<Order>(nrow, ncol, dim);
380  InputIter last = data_ptr.set(nrow * ncol, first);
381  const T *data = data_ptr.get();
382 
383  ::hid_t datafile;
384  if (append) {
385  datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
386  } else {
387  datafile = ::H5Fcreate(
388  file_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
389  }
390  ::hid_t dataspace = ::H5Screate_simple(2, dim, nullptr);
391  ::hid_t datatype = hdf5io_datatype<T>();
392  ::hid_t dataset = ::H5Dcreate(datafile, dataset_name.c_str(), datatype,
393  dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
394  ::H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
395 
396  ::H5Dclose(dataset);
397  ::H5Tclose(datatype);
398  ::H5Sclose(dataspace);
399  ::H5Fclose(datafile);
400 
401  return last;
402 }
403 
412 inline void hdf5store_list_empty(const std::string &file_name,
413  const std::string &data_name, bool append = false)
414 {
415  std::string group_name("/" + data_name);
416 
417  ::hid_t datafile;
418  if (append) {
419  datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
420  } else {
421  datafile = ::H5Fcreate(
422  file_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
423  }
424  ::hid_t datagroup = ::H5Gcreate(
425  datafile, group_name.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
426  ::H5Gclose(datagroup);
427  ::H5Fclose(datafile);
428 }
429 
457 template <typename T, typename InputIterIter, typename SInputIter>
458 inline void hdf5store_list(std::size_t nrow, std::size_t ncol,
459  const std::string &file_name, const std::string &data_name,
460  InputIterIter first, SInputIter sfirst, bool append = false)
461 {
462  std::string group_name("/" + data_name);
463  ::hsize_t dim[1] = {nrow};
464 
465  ::hid_t datafile;
466  if (append) {
467  datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
468  } else {
469  datafile = ::H5Fcreate(
470  file_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
471  }
472  ::hid_t datagroup = ::H5Gcreate(
473  datafile, group_name.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
474 
475  if (nrow != 0 && ncol != 0) {
476  ::hid_t dataspace = ::H5Screate_simple(1, dim, nullptr);
477  ::hid_t datatype = hdf5io_datatype<T>();
479  for (std::size_t j = 0; j != ncol; ++j, ++first, ++sfirst) {
480  data_ptr.set(nrow, *first);
481  const T *data = data_ptr.get();
482  std::string dataset_name(group_name + "/" + (*sfirst));
483  ::hid_t dataset = ::H5Dcreate(datafile, dataset_name.c_str(),
484  datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
485  ::H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
486  ::H5Dclose(dataset);
487  }
488  ::H5Tclose(datatype);
489  ::H5Sclose(dataspace);
490  }
491 
492  ::H5Gclose(datagroup);
493  ::H5Fclose(datafile);
494 }
495 
505 template <typename T, typename InputIter>
506 inline void hdf5store_list_insert(std::size_t N, const std::string &file_name,
507  const std::string &data_name, InputIter first, const std::string &vname)
508 {
509  if (N == 0)
510  return;
511 
512  std::string dataset_name("/" + data_name + "/" + vname);
513  ::hsize_t dim[1] = {N};
514 
515  ::hid_t datafile = ::H5Fopen(file_name.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
516  ::hid_t dataspace = ::H5Screate_simple(1, dim, nullptr);
517  ::hid_t datatype = hdf5io_datatype<T>();
519  data_ptr.set(N, first);
520  const T *data = data_ptr.get();
521  ::hid_t dataset = ::H5Dcreate(datafile, dataset_name.c_str(), datatype,
522  dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
523  ::H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
524 
525  ::H5Dclose(dataset);
526  ::H5Tclose(datatype);
527  ::H5Sclose(dataspace);
528  ::H5Fclose(datafile);
529 }
530 
531 namespace internal
532 {
533 
534 template <typename InputIter, typename... InputIters>
535 inline void hdf5store_list_insert_tuple(std::size_t nrow,
536  const std::string &file_name, const std::string &data_name,
537  const std::tuple<InputIter, InputIters...> &first, const std::string *sptr,
538  std::integral_constant<std::size_t, 0>)
539 {
540  using value_type =
541  typename std::iterator_traits<typename std::tuple_element<0,
542  std::tuple<InputIter, InputIters...>>::type>::value_type;
544  data_ptr.set(nrow, std::get<0>(first));
545  const value_type *data = data_ptr.get();
546  hdf5store_list_insert<value_type>(nrow, file_name, data_name, data, *sptr);
547 }
548 
549 template <typename InputIter, typename... InputIters, std::size_t Pos>
550 inline void hdf5store_list_insert_tuple(std::size_t nrow,
551  const std::string &file_name, const std::string &data_name,
552  const std::tuple<InputIter, InputIters...> &first, const std::string *sptr,
553  std::integral_constant<std::size_t, Pos>)
554 {
555  using value_type =
556  typename std::iterator_traits<typename std::tuple_element<Pos,
557  std::tuple<InputIter, InputIters...>>::type>::value_type;
559  data_ptr.set(nrow, std::get<Pos>(first));
560  const value_type *data = data_ptr.get();
561  hdf5store_list_insert<value_type>(nrow, file_name, data_name, data, *sptr);
562  hdf5store_list_insert_tuple(nrow, file_name, data_name, first, --sptr,
563  std::integral_constant<std::size_t, Pos - 1>());
564 }
565 
566 } // namespace vsmc::internal
567 
587 template <typename SInputIter, typename InputIter, typename... InputIters>
588 inline void hdf5store_list(std::size_t nrow, const std::string &file_name,
589  const std::string &data_name,
590  const std::tuple<InputIter, InputIters...> &first, SInputIter sfirst,
591  bool append = false)
592 {
593  static constexpr std::size_t dim = sizeof...(InputIters) + 1;
595  vnames.set(dim, sfirst);
596  const std::string *sptr = vnames.get() + dim;
597  hdf5store_list_empty(file_name, data_name, append);
598  internal::hdf5store_list_insert_tuple(nrow, file_name, data_name, first,
599  --sptr, std::integral_constant<std::size_t, dim - 1>());
600 }
601 
602 namespace internal
603 {
604 
605 template <typename IntType>
606 inline bool hdf5store_int(std::size_t n, IntType *r, std::false_type)
607 {
608  if (sizeof(int) > sizeof(IntType))
609  return true;
610 
611  bool flag = true;
612  for (std::size_t i = 0; i != n; ++i) {
613  if (r[i] > std::numeric_limits<int>::max VSMC_MNE()) {
614  flag = false;
615  break;
616  }
617  }
618 
619  return flag;
620 }
621 
622 template <typename IntType>
623 inline bool hdf5store_int(std::size_t n, IntType *r, std::true_type)
624 {
625  if (sizeof(int) > sizeof(IntType))
626  return true;
627 
628  bool flag = true;
629  for (std::size_t i = 0; i != n; ++i) {
630  if (r[i] < std::numeric_limits<int>::min VSMC_MNE()) {
631  flag = false;
632  break;
633  }
634  if (r[i] > std::numeric_limits<int>::max VSMC_MNE()) {
635  flag = false;
636  break;
637  }
638  }
639 
640  return flag;
641 }
642 
643 } // namespace vsmc::internal
644 
647 template <typename T>
648 inline void hdf5store(const Sampler<T> &sampler, const std::string &file_name,
649  const std::string &data_name, bool append = false)
650 {
651  using size_type = typename Sampler<T>::size_type;
652 
653  std::size_t nrow = sampler.iter_size();
654 
655  if (nrow == 0)
656  return;
657 
658  hdf5store_list_empty(file_name, data_name, append);
659 
660  std::size_t ncol_int = sampler.summary_header_size_int();
661  Vector<std::string> header_int(ncol_int);
662  Vector<size_type> data_int(nrow * ncol_int);
663  sampler.summary_header_int(header_int.begin());
664  sampler.template summary_data_int<ColMajor>(data_int.begin());
665  bool use_int = internal::hdf5store_int(
666  data_int.size(), data_int.data(), std::is_signed<size_type>());
667  if (use_int) {
668  Vector<int> data_int_small(data_int.size());
669  std::copy(data_int.begin(), data_int.end(), data_int_small.begin());
670  Vector<const int *> data_ptr_int(ncol_int);
671  for (std::size_t j = 0; j != ncol_int; ++j)
672  data_ptr_int[j] = data_int_small.data() + j * nrow;
673  for (std::size_t j = 0; j != ncol_int; ++j)
674  hdf5store_list_insert<int>(
675  nrow, file_name, data_name, data_ptr_int[j], header_int[j]);
676  } else {
677  Vector<const size_type *> data_ptr_int(ncol_int);
678  for (std::size_t j = 0; j != ncol_int; ++j)
679  data_ptr_int[j] = data_int.data() + j * nrow;
680  for (std::size_t j = 0; j != ncol_int; ++j)
681  hdf5store_list_insert<size_type>(
682  nrow, file_name, data_name, data_ptr_int[j], header_int[j]);
683  }
684 
685  std::size_t ncol = sampler.summary_header_size();
686  Vector<std::string> header(ncol);
687  Vector<double> data(nrow * ncol);
688  sampler.summary_header(header.begin());
689  sampler.template summary_data<ColMajor>(data.begin());
690  Vector<const double *> data_ptr(ncol);
691  for (std::size_t j = 0; j != ncol; ++j)
692  data_ptr[j] = data.data() + j * nrow;
693  for (std::size_t j = 0; j != ncol; ++j)
694  hdf5store_list_insert<double>(
695  nrow, file_name, data_name, data_ptr[j], header[j]);
696 }
697 
700 template <MatrixOrder Order, std::size_t Dim, typename T>
701 inline void hdf5store(const StateMatrix<Order, Dim, T> &state,
702  const std::string &file_name, const std::string &data_name,
703  bool append = false)
704 {
705  hdf5store_matrix<Order, T>(
706  state.size(), state.dim(), file_name, data_name, state.data(), append);
707 }
708 
711 template <MatrixOrder Order, typename T, std::size_t StateSize,
712  typename RealType, typename ID>
714  const std::string &file_name, const std::string &data_name,
715  bool append = false)
716 {
717  std::size_t nrow = state.size();
718  std::size_t ncol = state.state_size() / sizeof(T);
719  std::size_t N = nrow * ncol;
720  Vector<T> data(N);
721  state.manager().template read_buffer<T>(
722  state.state_buffer().data(), N, data.data());
723  hdf5store_matrix<Order, T>(
724  nrow, ncol, file_name, data_name, data.data(), append);
725 }
726 
729 template <typename T>
730 inline void hdf5store(const Particle<T> &particle,
731  const std::string &file_name, const std::string &data_name,
732  bool append = false)
733 {
734  hdf5store_list_empty(file_name, data_name, append);
735  hdf5store(particle.value(), file_name, data_name + "/value", true);
736  hdf5store_matrix<ColMajor, double>(particle.size(), 1, file_name,
737  data_name + "/weight", particle.weight().data(), true);
738 }
739 
742 template <MatrixOrder Order, typename T, typename U>
743 inline void hdf5store(const Particle<U> &particle,
744  const std::string &file_name, const std::string &data_name,
745  bool append = false)
746 {
747  hdf5store_list_empty(file_name, data_name, append);
748  hdf5store<Order, T>(
749  particle.value(), file_name, data_name + "/value", true);
750  hdf5store_matrix<ColMajor, double>(particle.size(), 1, file_name,
751  data_name + "/weight", particle.weight().data(), true);
752 }
753 
754 } // namespace vsmc
755 
756 #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
inline::hid_t hdf5io_datatype< double >()
HDF5 data type specialization for double.
Definition: hdf5io.hpp:233
std::size_t summary_header_size() const
The size of Sampler summary header (floating point data)
Definition: sampler.hpp:590
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:506
typename std::conditional< std::is_scalar< T >::value, std::vector< T, AlignedAllocator< T >>, std::vector< T >>::type Vector
AlignedVector for scalar type and std::vector for others.
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:213
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:369
void summary_header(OutputIter first) const
Sampler summary header (floating point data)
Definition: sampler.hpp:620
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:607
inline::hid_t hdf5io_datatype< unsigned int >()
HDF5 data type specialization for unsigned int.
Definition: hdf5io.hpp:185
void copy(std::size_t n, const T *x, std::size_t incx, T *y, std::size_t incy)
Copies vector to another vector.
Definition: cblas.hpp:82
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:62
#define VSMC_MNE
Definition: defines.hpp:38
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:458
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:535
void hdf5store_list_empty(const std::string &file_name, const std::string &data_name, bool append=false)
Create an empty list.
Definition: hdf5io.hpp:412
MatrixOrder
Matrix order.
Definition: defines.hpp:53
std::size_t summary_header_size_int() const
The size of Sampler summary header (integer data, size etc.)
Definition: sampler.hpp:581
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:59
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:606
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:648