6 #ifndef ECHELON_MULTI_ARRAY_VIEW_HPP 7 #define ECHELON_MULTI_ARRAY_VIEW_HPP 9 #include <echelon/range.hpp> 11 #include <echelon/detail/map_indices.hpp> 12 #include <echelon/detail/all_integral.hpp> 18 #include <type_traits> 44 : data_(data_), shape_(std::move(shape_))
63 template <
typename... Indices,
typename Enabler =
typename std::enable_if<
64 detail::all_integral<Indices...>::value>
::type>
67 static_assert(detail::all_integral<Indices...>::value,
68 "All indices must be of integral type.");
70 return data_[detail::map_indices(shape_, indices...)];
87 template <
typename... Indices,
typename Enabler =
typename std::enable_if<
88 detail::all_integral<Indices...>::value>
::type>
91 static_assert(detail::all_integral<Indices...>::value,
92 "All indices must be of integral type.");
94 return data_[detail::map_indices(shape_, indices...)];
105 template <
typename... Args,
typename Enabler =
typename std::enable_if<
106 !detail::all_integral<Args...>::value>
::type>
109 return echelon::make_slice(*
this, std::forward<Args>(args)...);
132 const std::vector<std::size_t>&
shape()
const 139 std::vector<std::size_t> shape_;
echelon's core namespace
Definition: attribute.cpp:10
value_type & operator()(Indices...indices)
Accesses a specified element.
Definition: multi_array_view.hpp:89
const value_type * data() const
Direct access to the underlying array.
Definition: multi_array_view.hpp:116
A handle to an HDF5 type.
Definition: type.hpp:21
A multidimensional view onto an array.
Definition: multi_array_view.hpp:28
T value_type
value type of the array
Definition: multi_array_view.hpp:32
echelon::hdf5::array_slice< T > operator()(Args...args)
Slice the array.
Definition: multi_array_view.hpp:107
const std::vector< std::size_t > & shape() const
The shape of the array.
Definition: multi_array_view.hpp:132
value_type * data()
Direct access to the underlying array.
Definition: multi_array_view.hpp:125
multi_array_view(T *data_, std::vector< std::size_t > shape_)
Constructs a new view for a given array using a given shape.
Definition: multi_array_view.hpp:43
const value_type & operator()(Indices...indices) const
Accesses a specified element.
Definition: multi_array_view.hpp:65