예제 #1
0
 std::c14::enable_if_t<is_amv_value_or_view_class<ArrayType>::value && !has_scalar_or_string_value_type<ArrayType>::value>
 h5_read(h5::group gr, std::string name, ArrayType& a) {
  static_assert(!std::is_const<ArrayType>::value, "Cannot read in const object");
  auto gr2 = gr.open_group(name);
  // TODO checking scheme...
  // load the shape
  auto sha2 = a.shape();
  array<int, 1> sha;
  h5_read(gr2, "shape", sha);
  if (first_dim(sha) != sha2.size())
   TRIQS_RUNTIME_ERROR << " array<array<...>> load : rank mismatch. Expected " << sha2.size()<< " Got " << first_dim(sha);
  for (int u = 0; u < sha2.size(); ++u) sha2[u] = sha(u);
  if (a.shape() != sha2) a.resize(sha2);
#ifndef __cpp_generic_lambdas
  foreach(a, h5_impl::_load_lambda<ArrayType>{a, gr2});
#else
  foreach(a, [&](auto... is) { h5_read(gr2, h5_impl::_h5_name(is...), a(is...)); });
#endif
 }
예제 #2
0
 std::c14::enable_if_t<is_amv_value_or_view_class<ArrayType>::value && !has_scalar_or_string_value_type<ArrayType>::value>
 h5_write(h5::group gr, std::string name, ArrayType const& a) {
  if (a.is_empty()) TRIQS_RUNTIME_ERROR << " Cannot save an empty array into hdf5";
  auto gr2 = gr.create_group(name);
  gr2.write_triqs_hdf5_data_scheme(a);
  // save the shape
  array<int, 1> sha(ArrayType::rank);
  for (int u = 0; u < ArrayType::rank; ++u) sha(u) = a.shape()[u];
  h5_write(gr2, "shape", sha);
#ifndef __cpp_generic_lambdas
  foreach(a, h5_impl::_save_lambda<ArrayType>{a, gr2});
#else
  foreach(a, [&](auto... is) { h5_write(gr2, h5_impl::_h5_name(is...), a(is...)); });
#endif
 }
예제 #3
0
array_view<typename ArrayType::value_type, ArrayType::rank-1> sum0 (ArrayType const & A) {
 array<typename ArrayType::value_type, ArrayType::rank-1> res = A(0,ellipsis());
 for (size_t u =1; u< A.shape()[0]; ++u) res += A(u,ellipsis());
 return res;
}