22#ifndef LIBH5_ARRAY_INTERFACE_HPP
23#define LIBH5_ARRAY_INTERFACE_HPP
33namespace h5::array_interface {
52 [[nodiscard]]
int rank()
const {
return static_cast<int>(
lengths.size()); }
118 if (has_cplx_trailing_dim) {
128 [[nodiscard]]
int rank()
const {
return static_cast<int>(
count.size()); }
136 std::ranges::transform(
count,
block,
shape.begin(), std::multiplies<>());
141 [[nodiscard]]
auto size()
const {
143 return std::accumulate(sh.begin(), sh.end(), (
hsize_t)1, std::multiplies<>());
198 [[nodiscard]]
int rank()
const {
return slab.rank(); }
252 void write(
group g, std::string
const &name, array_view
const &v,
bool compress);
265 void write_slice(
group g, std::string
const &name, array_view
const &v, hyperslab sl);
274 void write_attribute(
object obj, std::string
const &name, array_view v);
284 void read(
group g, std::string
const &name, array_view v, hyperslab sl = {});
293 void read_attribute(
object obj, std::string
const &name, array_view v);
A handle to an HDF5 group.
Provides a handle to an HDF5 group and various methods to simplify the creation/opening of subgroups,...
object datatype
Type alias for an HDF5 datatype.
object dataset
Type alias for an HDF5 dataset.
void read_attribute(object obj, std::string const &name, array_view v)
Read from an HDF5 attribute into an array view.
void write_slice(group g, std::string const &name, array_view const &v, hyperslab sl)
Write an array view to a selected hyperslab of an existing HDF5 dataset.
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.
void write(group g, std::string const &name, array_view const &v, bool compress)
Write an array view to an HDF5 dataset.
std::pair< v_t, v_t > get_parent_shape_and_h5_strides(long const *np_strides, int rank, long const *view_shape)
Given a view on an n-dimensional array (dataspace) by specifying its numpy/nda-style strides and its ...
std::vector< hsize_t > v_t
Vector of h5::hsize_t used throughout the h5 library.
unsigned long long hsize_t
Size type used in HDF5.
Provides a generic handle for HDF5 objects.
void * start
Pointer to the data of the array.
v_t parent_shape
Shape of the (contiguous) parent array.
bool has_cplx_trailing_dim
datatype ty
h5::datatype stored in the array.
int rank() const
Get the rank of the view (including the possible added imaginary dimension).
array_view(datatype ty, void *start, int rank, bool has_cplx_trailing_dim)
Construct a new empty array view.
hyperslab slab
h5::array_interface::hyperslab specifying the selection of the view.
Simple struct to store basic information about an HDF5 dataset.
int rank() const
Get the rank of the dataspace in the dataset.
bool has_complex_attribute
Whether the stored values are complex.
v_t lengths
Shape of the dataspace in the dataset.
datatype ty
h5::datatype stored in the dataset.
Struct representing an HDF5 hyperslab.
auto size() const
Get the total number of elements in the hyperslab.
v_t block
Shape of a single block selected from the dataspace.
bool empty() const
Check whether the hyperslab is empty (has been initialized).
hyperslab(int rank, bool has_cplx_trailing_dim)
Construct a new empty hyperslab for a dataspace of a given rank.
v_t stride
Stride in each dimension (in the HDF5 sense).
v_t offset
Index offset for each dimension.
v_t count
Number of elements or blocks to select along each dimension.
hyperslab()=default
Default constructor leaves the hyperslab empty (uninitialized).
v_t shape() const
Get the shape of the selected hyperslab.
int rank() const
Get the rank of the hyperslab (including the possible added imaginary dimension).