SyDEVS  v0.6.7
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sydevs::arraynd< T, 1 > Class Template Reference

A one-dimensional (1D) specialization of the arraynd multidimensional array template. More...

#include <arraynd.h>

Inherits sydevs::arraynd_base< T, 1 >.

Public Member Functions

 arraynd ()
 Constructs a 1D arraynd object of length zero. More...
 
 arraynd (const std::array< int64, 1 > &dims, const T &value)
 Constructs a 1D arraynd object with the length specified in dims[0] and all elements initialized to value. More...
 
 arraynd (const std::array< int64, 1 > &dims, const std::vector< T > &data)
 Constructs a 1D arraynd object with the length specified in dims[0] and elements initialized with the supplied data. More...
 
 arraynd (const std::array< int64, 1 > &dims, std::function< T(const std::array< int64, 1 > &indices)> func)
 Constructs a 1D arraynd object with the length specified in dims[0] and elements initialized using the function object func. More...
 
 arraynd (const arraynd< T, 1 > &)=default
 Copy constructor (if rhs.is_view(), data is shared; otherwise data is copied) More...
 
arraynd< T, 1 > & operator= (const arraynd< T, 1 > &)=default
 Copy assignment (if rhs.is_view(), data is shared; otherwise data is copied) More...
 
 arraynd (arraynd< T, 1 > &&)=default
 Move constructor (data is shared) More...
 
arraynd< T, 1 > & operator= (arraynd< T, 1 > &&)=default
 Move assignment (data is shared) More...
 
 ~arraynd ()=default
 Destructor. More...
 
const T & operator[] (int64 index) const
 Create a const reference to the element at the specified index. More...
 
T & operator[] (int64 index)
 Create a reference to the element at the specified index. More...
 
const arraynd< T, 1 > operator[] (range r) const
 Create a const slice with the dimension filtered by referencing elements in the specified range r (data is shared). More...
 
arraynd< T, 1 > operator[] (range r)
 Create a slice with the dimension filtered by referencing elements in the specified range r (data is shared). More...
 
const arraynd< T, 1 > view () const
 Create a const view of the 1D multidimensional array (data is shared). More...
 
arraynd< T, 1 > view ()
 Create a view of the 1D multidimensional array (data is shared). More...
 
arraynd< T, 1 > copy () const
 Create a deep copy of the 1D multidimensional array (data is copied). More...
 
const arraynd< T, 2 > view_subdivided_axis (int64 idim, const std::array< int64, 2 > &dims) const
 Create a const view with the single dimension split into two dimensions with lengths given by dims (data is shared). More...
 
arraynd< T, 2 > view_subdivided_axis (int64 idim, const std::array< int64, 2 > &dims)
 Create a view with the single dimension split into two dimensions with lengths given by dims (data is shared). More...
 
arraynd< T, 2 > copy_subdivided_axis (int64 idim, const std::array< int64, 2 > &dims) const
 Create a deep copy with the single dimension split into two dimensions with lengths given by dims (data is copied). More...
 
- Public Member Functions inherited from sydevs::arraynd_base< T, 1 >
 ~arraynd_base ()=default
 Destructor. More...
 
std::array< int64, ndims > dims () const
 Returns the lengths of each dimension. More...
 
std::array< int64, ndims > strides () const
 Returns the number of element-size steps in memory between successive elements for each dimension. More...
 
bool empty () const
 Returns true if there is at least one element. More...
 
int64 size () const
 Returns the total number of elements. More...
 
int64 offset () const
 Returns the number of element-size steps in memory before the first element. More...
 
const T * data () const
 Returns a pointer to the element data (const). More...
 
T * data ()
 Returns a pointer to the element data. More...
 
bool is_contiguous () const
 Returns true if a row-major traversal of the multidimensional array accesses each element of data in sequence. More...
 
bool is_view () const
 Returns true if this multidimensional array is a view of another, meaning that data is shared. More...
 
bool is_readonly () const
 Returns true if the data is readonly, in which case attempts to modify it raise a std::logic_error. More...
 
const T & operator() (const std::array< int64, ndims > &indices) const
 Returns a reference to an element (const). More...
 
T & operator() (const std::array< int64, ndims > &indices)
 Returns a reference to an element. More...
 
const T & operator() (const arraynd_base< int64, 1 > &indices) const
 Returns a reference to an element (const). More...
 
T & operator() (const arraynd_base< int64, 1 > &indices)
 Returns a reference to an element. More...
 
const T & operator() (Indices...indices) const
 Returns a reference to an element (const). More...
 
T & operator() (Indices...indices)
 Returns a reference to an element. More...
 
void fill (const T &value)
 Replaces every element with value. More...
 
void assign (const arraynd_base< T, ndims > &rhs)
 Replaces every element with the corresponding value in rhs. More...
 
void assign_from_function (std::function< T(const std::array< int64, ndims > &indices)> func)
 Replaces every element with the result of func evaluated at the cooresponding indices. More...
 
bool traverse (std::function< bool(const std::array< int64, ndims > &indices, const T &value)> func) const
 Traverses the multidimensional array in row-major order, calling func at every element. More...
 

Friends

class arraynd< T, 2 >
 

Additional Inherited Members

- Protected Member Functions inherited from sydevs::arraynd_base< T, 1 >
 arraynd_base ()
 
 arraynd_base (const std::array< int64, ndims > &dims, const T &value)
 
 arraynd_base (const std::array< int64, ndims > &dims, const std::vector< T > &data)
 
 arraynd_base (const std::array< int64, ndims > &dims, std::function< T(const std::array< int64, ndims > &indices)> func)
 
 arraynd_base (const arraynd_base< T, ndims+1 > &rhs, int64 index, bool is_readonly)
 
 arraynd_base (const arraynd_base< T, ndims > &rhs, range r, bool is_readonly)
 
 arraynd_base (const arraynd_base< T, ndims > &rhs, bool is_view, bool is_readonly)
 
 arraynd_base (const arraynd_base< T, ndims > &rhs)
 
 arraynd_base (arraynd_base< T, ndims > &&)=default
 
arraynd_base< T, ndims > & operator= (const arraynd_base< T, ndims > &rhs)
 
arraynd_base< T, ndims > & operator= (arraynd_base< T, ndims > &&)=default
 
- Static Protected Member Functions inherited from sydevs::arraynd_base< T, 1 >
static void transpose (arraynd_base< T, ndims > &arr)
 
static void swap_axes (arraynd_base< T, ndims > &arr, int64 idim0, int64 idim1)
 
static void subdivide_axis (const arraynd_base< T, ndims > &arr0, arraynd_base< T, ndims+1 > &arr, int64 idim, const std::array< int64, 2 > &dims)
 
static void absorb_axis (const arraynd_base< T, ndims > &arr0, arraynd_base< T, ndims-1 > &arr, int64 idim)
 

Detailed Description

template<typename T>
class sydevs::arraynd< T, 1 >

A one-dimensional (1D) specialization of the arraynd multidimensional array template.

Constructor & Destructor Documentation

template<typename T >
sydevs::arraynd< T, 1 >::arraynd ( )

Constructs a 1D arraynd object of length zero.

template<typename T >
sydevs::arraynd< T, 1 >::arraynd ( const std::array< int64, 1 > &  dims,
const T &  value 
)

Constructs a 1D arraynd object with the length specified in dims[0] and all elements initialized to value.

template<typename T >
sydevs::arraynd< T, 1 >::arraynd ( const std::array< int64, 1 > &  dims,
const std::vector< T > &  data 
)

Constructs a 1D arraynd object with the length specified in dims[0] and elements initialized with the supplied data.

The supplied data vector must have a length equal to dims[0] so that the 1D multidimensional array can be filled. Otherwise, a std::domain_error exception is thrown. The elements ofdata` are copied into the multidimensional array in row-major order.

Parameters
dimsThe dimensions.
dataA vector of values to be copied into the multidimensional array.
template<typename T >
sydevs::arraynd< T, 1 >::arraynd ( const std::array< int64, 1 > &  dims,
std::function< T(const std::array< int64, 1 > &indices)>  func 
)

Constructs a 1D arraynd object with the length specified in dims[0] and elements initialized using the function object func.

The function object func maps a set of indices to the value that will be assigned to the corresponding location in the 1D multidimensional array.

Parameters
dimsThe dimensions.
funcThe function object invoked to initialize each element.
template<typename T>
sydevs::arraynd< T, 1 >::arraynd ( const arraynd< T, 1 > &  )
default

Copy constructor (if rhs.is_view(), data is shared; otherwise data is copied)

template<typename T>
sydevs::arraynd< T, 1 >::arraynd ( arraynd< T, 1 > &&  )
default

Move constructor (data is shared)

template<typename T>
sydevs::arraynd< T, 1 >::~arraynd ( )
default

Destructor.

Member Function Documentation

template<typename T >
arraynd< T, 1 > sydevs::arraynd< T, 1 >::copy ( ) const

Create a deep copy of the 1D multidimensional array (data is copied).

template<typename T >
arraynd< T, 2 > sydevs::arraynd< T, 1 >::copy_subdivided_axis ( int64  idim,
const std::array< int64, 2 > &  dims 
) const

Create a deep copy with the single dimension split into two dimensions with lengths given by dims (data is copied).

template<typename T>
arraynd<T, 1>& sydevs::arraynd< T, 1 >::operator= ( const arraynd< T, 1 > &  )
default

Copy assignment (if rhs.is_view(), data is shared; otherwise data is copied)

template<typename T>
arraynd<T, 1>& sydevs::arraynd< T, 1 >::operator= ( arraynd< T, 1 > &&  )
default

Move assignment (data is shared)

template<typename T >
const T & sydevs::arraynd< T, 1 >::operator[] ( int64  index) const

Create a const reference to the element at the specified index.

template<typename T >
T & sydevs::arraynd< T, 1 >::operator[] ( int64  index)

Create a reference to the element at the specified index.

template<typename T >
const arraynd< T, 1 > sydevs::arraynd< T, 1 >::operator[] ( range  r) const

Create a const slice with the dimension filtered by referencing elements in the specified range r (data is shared).

template<typename T >
arraynd< T, 1 > sydevs::arraynd< T, 1 >::operator[] ( range  r)

Create a slice with the dimension filtered by referencing elements in the specified range r (data is shared).

template<typename T >
const arraynd< T, 1 > sydevs::arraynd< T, 1 >::view ( ) const

Create a const view of the 1D multidimensional array (data is shared).

template<typename T >
arraynd< T, 1 > sydevs::arraynd< T, 1 >::view ( )

Create a view of the 1D multidimensional array (data is shared).

template<typename T >
const arraynd< T, 2 > sydevs::arraynd< T, 1 >::view_subdivided_axis ( int64  idim,
const std::array< int64, 2 > &  dims 
) const

Create a const view with the single dimension split into two dimensions with lengths given by dims (data is shared).

template<typename T >
arraynd< T, 2 > sydevs::arraynd< T, 1 >::view_subdivided_axis ( int64  idim,
const std::array< int64, 2 > &  dims 
)

Create a view with the single dimension split into two dimensions with lengths given by dims (data is shared).

Friends And Related Function Documentation

template<typename T>
friend class arraynd< T, 2 >
friend

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