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()); }
125 [[nodiscard]]
int rank()
const {
return static_cast<int>(
count.size()); }
138 [[nodiscard]]
auto size()
const {
140 return std::accumulate(sh.begin(), sh.end(), (
hsize_t)1, std::multiplies<>());
242 void write(
group g, std::string
const &name, array_view
const &v,
bool compress);
255 void write_slice(
group g, std::string
const &name, array_view
const &v, hyperslab sl);
264 void write_attribute(
object obj, std::string
const &name, array_view v);
274 void read(
group g, std::string
const &name, array_view v, hyperslab sl = {});
283 void read_attribute(
object obj, std::string
const &name, array_view v);
A handle to an HDF5 group.
A generic handle for HDF5 objects.
Provides a handle to an HDF5 group and various methods to simplify the creation/opening of subgroups,...
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 view_size)
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.
Struct representing a view on an n-dimensional array/dataspace.
void * start
Pointer to the data of the array.
array_view(datatype ty, void *start, int rank, bool is_complex)
Construct a new empty array view.
v_t parent_shape
Shape of the (contiguous) parent array.
datatype ty
h5::datatype stored in the array.
bool is_complex
Whether the data is complex valued.
int rank() const
Get the rank of the view (including the possible added imaginary dimension).
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).
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).
hyperslab(int rank, bool is_complex)
Construct a new empty hyperslab for a dataspace of a given rank.
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).