mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
mf::ndarray< Dim, T, Allocator > Class Template Reference

Multidimensional array container. More...

#include <ndarray.h>

Public Types

using view_type = ndarray_view< Dim, T >
 
using const_view_type = ndarray_view< Dim, const T >
 
using index_type = typename view_type::index_type
 
using coordinates_type = typename view_type::coordinates_type
 
using shape_type = typename view_type::shape_type
 
using strides_type = typename view_type::strides_type
 
using span_type = typename view_type::span_type
 
using value_type = T
 
using pointer = T *
 
using const_pointer = const T *
 
using reference = T &
 
using const_reference = const T &
 
using iterator = typename view_type::iterator
 
using const_iterator = typename const_view_type::iterator
 

Public Member Functions

 ndarray (const shape_type &shp, const Allocator &allocator=Allocator())
 
 ndarray (const const_view_type &)
 
 ndarray (const ndarray &arr)
 
 ~ndarray ()
 
ndarrayoperator= (const const_view_type &arr)
 
ndarrayoperator= (const ndarray &arr)
 
view_type view ()
 
const_view_type view () const
 
const_view_type cview () const
 
 operator view_type () noexcept
 
 operator const_view_type () const noexcept
 
coordinates_type index_to_coordinates (const index_type &index) const
 
index_type coordinates_to_index (const coordinates_type &coord) const
 
pointer coordinates_to_pointer (const coordinates_type &coord)
 
const_pointer coordinates_to_pointer (const coordinates_type &coord) const
 
std::size_t size () const noexcept
 
pointer start () noexcept
 
const_pointer start () const noexcept
 
const shape_typeshape () const noexcept
 
const strides_typestrides () const noexcept
 
std::size_t contiguous_length () const noexcept
 
std::size_t padding () const noexcept
 
template<typename... Args>
decltype(auto) section (Args &&...args)
 
template<typename... Args>
decltype(auto) section (Args &&...args) const
 
template<typename... Args>
decltype(auto) slice (Args &&...args)
 
template<typename... Args>
decltype(auto) slice (Args &&...args) const
 
template<typename... Args>
decltype(auto) operator() (Args &&...args)
 
template<typename... Args>
decltype(auto) operator() (Args &&...args) const
 
template<typename... Args>
decltype(auto) operator[] (Args &&...args)
 
template<typename... Args>
decltype(auto) operator[] (Args &&...args) const
 
template<typename... Args>
decltype(auto) at (Args &&...args)
 
template<typename... Args>
decltype(auto) at (Args &&...args) const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 

Static Public Attributes

static constexpr std::size_t dimension = Dim
 

Protected Member Functions

void allocate_ ()
 
void deallocate_ ()
 
 ndarray (const shape_type &shape, std::size_t padding, std::size_t stride, const Allocator &allocator)
 Constructor for use by derived classes. More...
 
strides_type strides_with_padding_ (const shape_type &shape, std::size_t padding)
 

Protected Attributes

Allocator allocator_
 Raw allocator used to allocate memory, in bytes. More...
 
std::size_t stride_
 Stride of elements, in bytes. More...
 
std::size_t padding_
 Padding between frames, in bytes. More...
 
std::size_t allocated_size_ = 0
 Allocated memory size, in bytes. More...
 
view_type view_
 View used to access items. More...
 

Detailed Description

template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
class mf::ndarray< Dim, T, Allocator >

Multidimensional array container.

Based on ndarray_view, but also owns items. Allocates and deallocates memory. Const-correct interface. Uses default strides when created from public constructor. Derived classes (i.e. ring) can create ndarray with padding between elements (last dimension), and padding between frames (first dimension).

Member Typedef Documentation

template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::const_iterator = typename const_view_type::iterator
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::const_pointer = const T*
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::const_reference = const T&
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::const_view_type = ndarray_view<Dim, const T>
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::coordinates_type = typename view_type::coordinates_type
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::index_type = typename view_type::index_type
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::iterator = typename view_type::iterator
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::pointer = T*
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::reference = T&
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::shape_type = typename view_type::shape_type
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::span_type = typename view_type::span_type
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::strides_type = typename view_type::strides_type
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::value_type = T
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
using mf::ndarray< Dim, T, Allocator >::view_type = ndarray_view<Dim, T>

Constructor & Destructor Documentation

template<std::size_t Dim, typename T , typename Allocator>
mf::ndarray< Dim, T, Allocator >::ndarray ( const shape_type shape,
std::size_t  padding,
std::size_t  stride,
const Allocator &  allocator 
)
protected

Constructor for use by derived classes.

Size of allocated memory segment is shape.front() * (padding + shape.tail().product()*stride). Caller must ensure this satisfies requirements of allocator.

Parameters
shapeShape of entire array. First component is length of array, remaining components is frame shape.
paddingPadding between frames, in bytes.
strideStride of elements, in bytes. Must be multiple of alignof(T) and leq to sizeof(T).
allocatorAllocator instance.
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
mf::ndarray< Dim, T, Allocator >::ndarray ( const shape_type shp,
const Allocator &  allocator = Allocator() 
)
inlineexplicit
template<std::size_t Dim, typename T , typename Allocator>
mf::ndarray< Dim, T, Allocator >::ndarray ( const const_view_type in)
explicit
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
mf::ndarray< Dim, T, Allocator >::ndarray ( const ndarray< Dim, T, Allocator > &  arr)
inline
template<std::size_t Dim, typename T , typename Allocator >
mf::ndarray< Dim, T, Allocator >::~ndarray ( )

Member Function Documentation

template<std::size_t Dim, typename T , typename Allocator >
void mf::ndarray< Dim, T, Allocator >::allocate_ ( )
protected
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
template<typename... Args>
decltype(auto) mf::ndarray< Dim, T, Allocator >::at ( Args &&...  args)
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
template<typename... Args>
decltype(auto) mf::ndarray< Dim, T, Allocator >::at ( Args &&...  args) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
iterator mf::ndarray< Dim, T, Allocator >::begin ( )
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
const_iterator mf::ndarray< Dim, T, Allocator >::begin ( ) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
const_iterator mf::ndarray< Dim, T, Allocator >::cbegin ( ) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
const_iterator mf::ndarray< Dim, T, Allocator >::cend ( ) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
std::size_t mf::ndarray< Dim, T, Allocator >::contiguous_length ( ) const
inlinenoexcept
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
index_type mf::ndarray< Dim, T, Allocator >::coordinates_to_index ( const coordinates_type coord) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
pointer mf::ndarray< Dim, T, Allocator >::coordinates_to_pointer ( const coordinates_type coord)
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
const_pointer mf::ndarray< Dim, T, Allocator >::coordinates_to_pointer ( const coordinates_type coord) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
const_view_type mf::ndarray< Dim, T, Allocator >::cview ( ) const
inline
template<std::size_t Dim, typename T , typename Allocator >
void mf::ndarray< Dim, T, Allocator >::deallocate_ ( )
protected
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
iterator mf::ndarray< Dim, T, Allocator >::end ( )
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
const_iterator mf::ndarray< Dim, T, Allocator >::end ( ) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
coordinates_type mf::ndarray< Dim, T, Allocator >::index_to_coordinates ( const index_type index) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
mf::ndarray< Dim, T, Allocator >::operator const_view_type ( ) const
inlinenoexcept
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
mf::ndarray< Dim, T, Allocator >::operator view_type ( )
inlinenoexcept
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
template<typename... Args>
decltype(auto) mf::ndarray< Dim, T, Allocator >::operator() ( Args &&...  args)
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
template<typename... Args>
decltype(auto) mf::ndarray< Dim, T, Allocator >::operator() ( Args &&...  args) const
inline
template<std::size_t Dim, typename T , typename Allocator >
auto mf::ndarray< Dim, T, Allocator >::operator= ( const const_view_type arr)
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
ndarray& mf::ndarray< Dim, T, Allocator >::operator= ( const ndarray< Dim, T, Allocator > &  arr)
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
template<typename... Args>
decltype(auto) mf::ndarray< Dim, T, Allocator >::operator[] ( Args &&...  args)
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
template<typename... Args>
decltype(auto) mf::ndarray< Dim, T, Allocator >::operator[] ( Args &&...  args) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
std::size_t mf::ndarray< Dim, T, Allocator >::padding ( ) const
inlinenoexcept
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
template<typename... Args>
decltype(auto) mf::ndarray< Dim, T, Allocator >::section ( Args &&...  args)
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
template<typename... Args>
decltype(auto) mf::ndarray< Dim, T, Allocator >::section ( Args &&...  args) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
const shape_type& mf::ndarray< Dim, T, Allocator >::shape ( ) const
inlinenoexcept
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
std::size_t mf::ndarray< Dim, T, Allocator >::size ( ) const
inlinenoexcept
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
template<typename... Args>
decltype(auto) mf::ndarray< Dim, T, Allocator >::slice ( Args &&...  args) const
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
template<typename... Args>
decltype(auto) mf::ndarray< Dim, T, Allocator >::slice ( Args &&...  args)
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
pointer mf::ndarray< Dim, T, Allocator >::start ( )
inlinenoexcept
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
const_pointer mf::ndarray< Dim, T, Allocator >::start ( ) const
inlinenoexcept
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
const strides_type& mf::ndarray< Dim, T, Allocator >::strides ( ) const
inlinenoexcept
template<std::size_t Dim, typename T , typename Allocator >
auto mf::ndarray< Dim, T, Allocator >::strides_with_padding_ ( const shape_type shape,
std::size_t  padding 
)
protected
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
view_type mf::ndarray< Dim, T, Allocator >::view ( )
inline
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
const_view_type mf::ndarray< Dim, T, Allocator >::view ( ) const
inline

Member Data Documentation

template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
std::size_t mf::ndarray< Dim, T, Allocator >::allocated_size_ = 0
protected

Allocated memory size, in bytes.

template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
Allocator mf::ndarray< Dim, T, Allocator >::allocator_
protected

Raw allocator used to allocate memory, in bytes.

template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
constexpr std::size_t mf::ndarray< Dim, T, Allocator >::dimension = Dim
static
template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
std::size_t mf::ndarray< Dim, T, Allocator >::padding_
protected

Padding between frames, in bytes.

template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
std::size_t mf::ndarray< Dim, T, Allocator >::stride_
protected

Stride of elements, in bytes.

template<std::size_t Dim, typename T, typename Allocator = raw_allocator>
view_type mf::ndarray< Dim, T, Allocator >::view_
protected

View used to access items.


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