本文整理汇总了C++中h5::group类的典型用法代码示例。如果您正苦于以下问题:C++ group类的具体用法?C++ group怎么用?C++ group使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_array_lengths
std::vector<size_t> get_array_lengths(int R, h5::group g, std::string const& name, bool is_complex) {
h5::dataset ds = g.open_dataset(name);
h5::dataspace d_space = H5Dget_space(ds);
int Rank = R + (is_complex ? 1 : 0);
int rank = H5Sget_simple_extent_ndims(d_space);
if (rank != Rank)
TRIQS_RUNTIME_ERROR << "triqs::array::h5::read. Rank mismatch : the array has rank = " << Rank
<< " while the array stored in the hdf5 file has rank = " << rank;
std::vector<size_t> d2(R);
hsize_t dims_out[rank];
H5Sget_simple_extent_dims(d_space, dims_out, NULL);
for (int u = 0; u < R; ++u) d2[u] = dims_out[u];
return d2;
}
示例2: h5_write
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: h5_read
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
}
示例4: h5_write
/// Write into HDF5
friend void h5_write(h5::group fg, std::string subgroup_name, gf_mesh const& m) {
h5::group gr = fg.create_group(subgroup_name);
h5_write(gr, "dims", m.dims.to_vector());
}
示例5: h5_write
/**
@param fg Parent HDF5 group to write the space to
@param name Name of the HDF5 subgroup to be created
@param hs Hilbert subspace to be written
*/
friend void h5_write(h5::group fg, std::string const &name, sub_hilbert_space const &hs) {
auto gr = fg.create_group(name);
h5_write(gr, "index", hs.index);
h5_write(gr, "fock_states", hs.fock_states);
}
示例6: h5_read
/**
@param fg Parent HDF5 group to read the space from
@param name Name of the HDF5 subgroup to be read
@param hs Reference to a target Hilbert space object
*/
friend void h5_read(h5::group fg, std::string const &name, hilbert_space &hs) {
auto gr = fg.open_group(name);
h5_read(gr, "dim", hs.dim);
}
示例7: h5_read
/// Read from HDF5
friend void h5_read(h5::group fg, std::string subgroup_name, discrete_mesh &m) {
h5::group gr = fg.open_group(subgroup_name);
typename discrete_mesh::domain_t dom;
h5_read(gr, "domain", dom);
m = discrete_mesh(std::move(dom));
}
示例8: h5_write
/// Write into HDF5
friend void h5_write(h5::group fg, std::string subgroup_name, discrete_mesh const &m) {
h5::group gr = fg.create_group(subgroup_name);
h5_write(gr, "domain", m.domain());
}
示例9: h5_read
/// Read from HDF5
friend void h5_read(h5::group fg, std::string subgroup_name, gf_mesh &m) {
h5::group gr = fg.open_group(subgroup_name);
auto l = [gr](int N, auto &m) { h5_read(gr, "MeshComponent" + std::to_string(N), m); };
triqs::tuple::for_each_enumerate(m.components(), l);
}
示例10: h5_write
// HDF5 interface
friend void h5_write (h5::group g, std::string const & name, measure_set const & ms) {
auto gr = g.create_group(name);
for (auto & p : ms.m_map) h5_write(gr,p.first, p.second);
}
示例11: h5_read
friend void h5_read(h5::group fg, std::string subgroup_name, tail_impl &t) {
auto gr = fg.open_group(subgroup_name);
h5_read(gr, "omin", t.omin);
h5_read(gr, "mask", t._mask);
h5_read(gr, "data", t._data);
}
示例12: h5_write
friend void h5_write(h5::group fg, std::string subgroup_name, tail_impl const &t) {
auto gr = fg.create_group(subgroup_name);
h5_write(gr, "omin", t.omin);
h5_write(gr, "mask", t._mask);
h5_write(gr, "data", t._data);
}
示例13: h5_read
/// Read from HDF5
void h5_read(h5::group fg, std::string subgroup_name, bravais_lattice& bl) {
h5::group gr = fg.open_group(subgroup_name);
matrix<double> u;
h5_read(gr, "units", u);
bl = bravais_lattice{u}; // NOT COMPLETE
}
示例14: h5_write
/// Write into HDF5
void h5_write(h5::group fg, std::string subgroup_name, bravais_lattice const& bl) {
h5::group gr = fg.create_group(subgroup_name);
h5_write(gr, "units", bl.units_); // NOT COMPLETE
}
示例15: h5_read
/// Read from HDF5
friend void h5_read(h5::group fg, std::string subgroup_name, gf_mesh& m) {
h5::group gr = fg.open_group(subgroup_name);
auto dims = h5::h5_read<std::vector<int>>(gr, "dims");
m = gf_mesh(dims[0], dims[1], dims[2]);
}