22#ifndef LIBH5_SCALAR_HPP
23#define LIBH5_SCALAR_HPP
37 namespace array_interface {
70 void h5_write(
group g, std::string
const &name, T
const &x) H5_REQUIRES(std::is_arithmetic_v<T> or
is_complex_v<T> or std::is_same_v<T, dcplx_t>) {
88 if (g.has_subgroup(name)) {
91 double r = NAN, i = NAN;
94 x = std::complex<double>{r, i};
124 template <
typename T>
139 template <
typename T>
Provides a generic interface to read/write n-dimensional arrays from/to HDF5.
A handle to an HDF5 group.
group open_group(std::string const &key) const
Open a subgroup with the given key in the group.
bool has_key(std::string const &key) const
Check if a link with the given key exists in the group.
Provides a compound type and type traits for complex numbers.
Provides a handle to an HDF5 group and various methods to simplify the creation/opening of subgroups,...
bool hdf5_type_equal(datatype dt1, datatype dt2)
Check if two HDF5 datatypes are equal.
constexpr bool is_complex_v
Boolean type trait set to true for std::complex types.
datatype hdf5_type()
Map a given C++ type to an HDF5 datatype.
void read_attribute(object obj, std::string const &name, array_view v)
Read from an HDF5 attribute into an array view.
void read(group g, std::string const &name, array_view v, hyperslab sl)
Read a given hyperslab from an HDF5 dataset into an array view.
void write_attribute(object obj, std::string const &name, array_view v)
Write an array view to an HDF5 attribute.
dataset_info get_dataset_info(dataset ds)
Retrieve the shape and the h5::datatype from a dataset.
array_view array_view_from_scalar(T &x)
Create an array view for a scalar.
void write(group g, std::string const &name, array_view const &v, bool compress)
Write an array view to an HDF5 dataset.
T h5_read(group g, std::string const &key)
Generic implementation for reading from an HDF5 dataset/subgroup.
T h5_read_attribute(object obj, std::string const &name)
Generic implementation for reading an HDF5 attribute.
void h5_write(group g, std::string const &name, T const &x) H5_REQUIRES(std
Write a scalar to an HDF5 dataset.
void h5_write_attribute(object obj, std::string const &name, T const &x) H5_REQUIRES(std
Write a scalar to an HDF5 attribute.
Macros used in the h5 library.
Provides a generic handle for HDF5 objects.
Struct representing a view on an n-dimensional array/dataspace.
A complex compound type consisting of two doubles to represent a complex number.