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

An adapter, around a random-access sequence container, which behaves like a multidimensional array. More...

#include <multi_array_adapter.hpp>

Public Types

typedef Container::value_type value_type
 value type of the array
 

Public Member Functions

 multi_array_adapter (Container &container_, std::vector< std::size_t > shape_)
 Constructs a new adapter around a given container 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< value_typeoperator() (Args...args)
 Slice the array. More...
 
Container::iterator begin ()
 Returns an iterator, which points to the first element of the flattened array. More...
 
Container::iterator end ()
 Returns an iterator, which points to the last element of the flattened array. More...
 
Container::const_iterator begin () const
 Returns an iterator, which points to the first element of the flattened array. More...
 
Container::const_iterator end () const
 Returns an iterator, which points to the last element of the flattened 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 Container>
class echelon::multi_array_adapter< Container >

An adapter, around a random-access sequence container, which behaves like a multidimensional array.

Template Parameters
Containerthe type of the wrapped container. Container should provide random access.

Constructor & Destructor Documentation

template<typename Container >
echelon::multi_array_adapter< Container >::multi_array_adapter ( Container &  container_,
std::vector< std::size_t >  shape_ 
)
inline

Constructs a new adapter around a given container using a given shape.

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

Member Function Documentation

template<typename Container >
Container::iterator echelon::multi_array_adapter< Container >::begin ( )
inline

Returns an iterator, which points to the first element of the flattened array.

Note
The order, in which the elements appear in the flattened sequence, is not specified.
template<typename Container >
Container::const_iterator echelon::multi_array_adapter< Container >::begin ( ) const
inline

Returns an iterator, which points to the first element of the flattened array.

Note
The order, in which the elements appear in the flattened sequence, is not specified.
template<typename Container >
const value_type* echelon::multi_array_adapter< Container >::data ( ) const
inline

Direct access to the underlying array.

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

Direct access to the underlying array.

Returns
a pointer to the underlying array.
template<typename Container >
Container::iterator echelon::multi_array_adapter< Container >::end ( )
inline

Returns an iterator, which points to the last element of the flattened array.

Note
The order, in which the elements appear in the flattened sequence, is not specified.
template<typename Container >
Container::const_iterator echelon::multi_array_adapter< Container >::end ( ) const
inline

Returns an iterator, which points to the last element of the flattened array.

Note
The order, in which the elements appear in the flattened sequence, is not specified.
template<typename Container >
template<typename... Indices, typename Enabler = typename std::enable_if< detail::all_integral<Indices...>::value>::type>
const value_type& echelon::multi_array_adapter< Container >::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 Container >
template<typename... Indices, typename Enabler = typename std::enable_if< detail::all_integral<Indices...>::value>::type>
value_type& echelon::multi_array_adapter< Container >::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 Container >
template<typename... Args, typename Enabler = typename std::enable_if< !detail::all_integral<Args...>::value>::type>
echelon::hdf5::array_slice<value_type> echelon::multi_array_adapter< Container >::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: