ivl 679
array_nd< T, data::normal_2d< DERIVED_INFO > > Class Template Reference

Multi-dimensional array of type T. More...

#include <array_nd_2d_class.hpp>

Inherits array_common_base< array_nd< T, data::normal_2d< DERIVED_INFO > > >.

List of all members.

Public Types

typedef const size_dims< 2 > & size_nd_ref_type
 return type of size_nd in that data-specific class
typedef array< size_t, tiny > size_type
 parameter of resize, in each class of the hierarchy
typedef size_dims< 2 > stride_ref_type
 return type of size_nd in that data-specific class

Public Member Functions

base_class & base ()
 get base class
Element access (multidimensional)

Elements can be accessed by specifying the

T & operator() (size_t s1, size_t s2)
template<class S >
T & operator() (const array< size_t, S > &indx)
const T & operator() (size_t s1, size_t s2) const
template<class S >
const T & operator() (const array< size_t, S > &indx) const
Single-dimensional constructors
 array_nd ()
 Default constructor.
Multi-dimensional constructors
template<class S >
 array_nd (const array< size_t, S > &sz)
 Construct from a size_array containing the dimension sizes.
template<class S >
 array_nd (const array< size_t, S > &sz, const T &s)
 Construct from a size_array containing the dimension sizes and assign scalar.
template<class S >
 array_nd (const array< size_t, S > &sz, const T *ptr)
 Construct from a size_array containing the dimension sizes and assign values from an one-dimensional C array.
template<class S , class J , class D >
 array_nd (const array< size_t, S > &sz, const array< J, D > &a)
 Construct from a size_array containing the dimension sizes and an array with the values.
 array_nd (const this_type &a)
 Copy constructor.
template<class J , class S >
 array_nd (const array_nd< J, S > &a)
 Constructor using another form of array_nd.
Size functions (multidimensional)
size_nd_ref_type size_nd () const
 Get the size for each dimension.
size_t size_nd (size_t dim) const
 Get the size for a specific dimension.
stride_ref_type stride () const
 Get the stride for each dimension.
size_t stride (size_t dim) const
size_type size () const
 Get the size for each dimension.
size_t size (size_t dim) const
 Get the size for a specific dimension.
size_t ndims () const
 Get the number of dimensions.
Resize Functions
template<class S >
void resize (const array< size_t, S > &newsize, const T &s)
 resize (n-dim)
template<class S >
void resize (const array< size_t, S > &newsize)
 resize (n-dim) without padding
template<class S >
void reshape (const array< size_t, S > &newsize, const T &s)
 reshape (n-dim)
template<class S >
void reshape (const array< size_t, S > &newsize)
 reshape (n-dim) without padding
template<class S >
void init (const array< size_t, S > &newsize, const T &s)
 init (n-dim)
template<class S >
void init (const array< size_t, S > &newsize)
 init (n-dim) without padding
void init (const this_type &a)
Assignment Operators
template<class K >
derived_type & operator= (const K &k)
this_typeoperator= (const this_type &in)
 C++ copy-constructor.

Detailed Description

template<class T, class DERIVED_INFO>
class array_nd< T, data::normal_2d< DERIVED_INFO > >

Multi-dimensional array of type T.

This structure is used to define a multidimensional array of type T. The number of dimensions can be specified when constructing an object and can be altered anytime by using methods like resize(const size_array &, const T).

The simpliest way to access an array_nd element is by using operator() and specifying the offset on each dimension, like this:

 int i = a(2, 3, 2) 

An array_nd inherites all the functionality the array class provides, which means that it can also be indexed as an one-dimensional array using the array subscript operator: []. Keep in mind that in array_nd the elements are stored in column-major order like Fortr an and Matlab and not like C. So, the offset is computed like this:

offset = row + column*NUMROWS 

Member Function Documentation

template<class T , class DERIVED_INFO >
template<class S >
T& array_nd< T, data::normal_2d< DERIVED_INFO > >::operator() ( const array< size_t, S > &  indx) [inline]

Selects a single, mutable element of the array, using a size_array for the coordinates.

template<class T , class DERIVED_INFO >
template<class S >
const T& array_nd< T, data::normal_2d< DERIVED_INFO > >::operator() ( const array< size_t, S > &  indx) const [inline]

Selects a single, const element of the array, using a size_array for the coordinates.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations