echelon  0.8.0
Public Types | Public Member Functions | List of all members
echelon::multi_array_view< T > Class Template Reference

A multidimensional view onto an array. More...

#include <multi_array_view.hpp>

Public Types

using value_type = T
 value type of the array
 

Public Member Functions

 multi_array_view (T *data_, std::vector< std::size_t > shape_)
 Constructs a new view for a given array using a given shape. More...
 
template<typename... Indices, typename Enabler = typename std::enable_if< detail::all_integral<Indices...>::value>::type>
const value_typeoperator() (Indices...indices) const
 Accesses a specified element. More...
 
template<typename... Indices, typename Enabler = typename std::enable_if< detail::all_integral<Indices...>::value>::type>
value_typeoperator() (Indices...indices)
 Accesses a specified element. More...
 
template<typename... Args, typename Enabler = typename std::enable_if< !detail::all_integral<Args...>::value>::type>
echelon::hdf5::array_slice< T > operator() (Args...args)
 Slice the array. More...
 
const value_typedata () const
 Direct access to the underlying array. More...
 
value_typedata ()
 Direct access to the underlying array. More...
 
const std::vector< std::size_t > & shape () const
 The shape of the array.
 

Detailed Description

template<typename T>
class echelon::multi_array_view< T >

A multidimensional view onto an array.

Template Parameters
Tthe value type of the array

Constructor & Destructor Documentation

template<typename T >
echelon::multi_array_view< T >::multi_array_view ( T *  data_,
std::vector< std::size_t >  shape_ 
)
inline

Constructs a new view for a given array using a given shape.

Precondition
Let $ (s_1,...,s_{N}) $ be the requested shape and let $ s $ be the size of the underlying memory block, then $ \prod_{i} s_{i} = s $ should hold.
Parameters
container_the adapted container
shape_the shape of the array

Member Function Documentation

template<typename T >
const value_type* echelon::multi_array_view< T >::data ( ) const
inline

Direct access to the underlying array.

Returns
a pointer to the underlying array.
template<typename T >
value_type* echelon::multi_array_view< T >::data ( )
inline

Direct access to the underlying array.

Returns
a pointer to the underlying array.
template<typename T >
template<typename... Indices, typename Enabler = typename std::enable_if< detail::all_integral<Indices...>::value>::type>
const value_type& echelon::multi_array_view< T >::operator() ( Indices...  indices) const
inline

Accesses a specified element.

Template Parameters
IndicesTypes of the indices. All indices should have integral type.
Precondition
Let $ \left(s_1,...s_{rank}\right) $ be the shape of the array and let $ \left(i_1,...i_{rank_2}\right) $ be the tuple of indices, then $ rank = rank_2 $ and $ i_{i} < s_{i} $ for every $ i \in \left\{ 0,...,rank-1 \right\} $ should hold.
Parameters
indicesIndices of the requested element
Returns
the specified element
template<typename T >
template<typename... Indices, typename Enabler = typename std::enable_if< detail::all_integral<Indices...>::value>::type>
value_type& echelon::multi_array_view< T >::operator() ( Indices...  indices)
inline

Accesses a specified element.

Template Parameters
IndicesTypes of the indices. All indices should have integral type.
Precondition
Let $ \left(s_1,...s_{rank}\right) $ be the shape of the array and let $ \left(i_1,...i_{rank_2}\right) $ be the tuple of indices, then $ rank = rank_2 $ and $ i_{i} < s_{i} $ for every $ i \in \left\{ 0,...,rank-1 \right\} $ should hold.
Parameters
indicesIndices of the requested element
Returns
the specified element
template<typename T >
template<typename... Args, typename Enabler = typename std::enable_if< !detail::all_integral<Args...>::value>::type>
echelon::hdf5::array_slice<T> echelon::multi_array_view< T >::operator() ( Args...  args)
inline

Slice the array.

Template Parameters
Argstypes of the index range specifiers
Parameters
argsindex range specifiers
Returns
the specified slice.

The documentation for this class was generated from the following file: