SyDEVS
v0.6.7
Multiscale Simulation and Systems Modeling Library
|
A base class template for a multidimensional array with elements of type T
arranged in a lattice of ndim
dimensions.
More...
#include <arraynd_base.h>
Inherited by sydevs::arraynd< T, ndims >.
Public Member Functions | |
~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... | |
template<typename... Indices> | |
const T & | operator() (Indices...indices) const |
Returns a reference to an element (const). More... | |
template<typename... Indices> | |
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... | |
Protected Member Functions | |
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< T, ndims > & | operator= (const arraynd_base< T, ndims > &rhs) |
arraynd_base (arraynd_base< T, ndims > &&)=default | |
arraynd_base< T, ndims > & | operator= (arraynd_base< T, ndims > &&)=default |
Static Protected Member Functions | |
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) |
Friends | |
class | arraynd_base< T, ndims-1 > |
class | arraynd_base< T, ndims+1 > |
A base class template for a multidimensional array with elements of type T
arranged in a lattice of ndim
dimensions.
arraynd_base
contains all member variables, all member functions that behave the same for ndims == 1
and ndims > 1
, and all member functions that do not return a multidimensional array.
|
default |
Destructor.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protecteddefault |
|
staticprotected |
void sydevs::arraynd_base< T, ndims >::assign | ( | const arraynd_base< T, ndims > & | rhs | ) |
Replaces every element with the corresponding value in rhs
.
void sydevs::arraynd_base< T, ndims >::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
.
const T * sydevs::arraynd_base< T, ndims >::data | ( | ) | const |
Returns a pointer to the element data (const).
T * sydevs::arraynd_base< T, ndims >::data | ( | ) |
Returns a pointer to the element data.
std::array< int64, ndims > sydevs::arraynd_base< T, ndims >::dims | ( | ) | const |
Returns the lengths of each dimension.
bool sydevs::arraynd_base< T, ndims >::empty | ( | ) | const |
Returns true
if there is at least one element.
void sydevs::arraynd_base< T, ndims >::fill | ( | const T & | value | ) |
Replaces every element with value
.
bool sydevs::arraynd_base< T, ndims >::is_contiguous | ( | ) | const |
Returns true
if a row-major traversal of the multidimensional array accesses each element of data
in sequence.
bool sydevs::arraynd_base< T, ndims >::is_readonly | ( | ) | const |
Returns true
if the data is readonly, in which case attempts to modify it raise a std::logic_error.
bool sydevs::arraynd_base< T, ndims >::is_view | ( | ) | const |
Returns true
if this multidimensional array is a view of another, meaning that data is shared.
int64 sydevs::arraynd_base< T, ndims >::offset | ( | ) | const |
Returns the number of element-size steps in memory before the first element.
const T & sydevs::arraynd_base< T, ndims >::operator() | ( | const std::array< int64, ndims > & | indices | ) | const |
Returns a reference to an element (const).
T & sydevs::arraynd_base< T, ndims >::operator() | ( | const std::array< int64, ndims > & | indices | ) |
Returns a reference to an element.
const T & sydevs::arraynd_base< T, ndims >::operator() | ( | const arraynd_base< int64, 1 > & | indices | ) | const |
Returns a reference to an element (const).
T & sydevs::arraynd_base< T, ndims >::operator() | ( | const arraynd_base< int64, 1 > & | indices | ) |
Returns a reference to an element.
const T & sydevs::arraynd_base< T, ndims >::operator() | ( | Indices... | indices | ) | const |
Returns a reference to an element (const).
T & sydevs::arraynd_base< T, ndims >::operator() | ( | Indices... | indices | ) |
Returns a reference to an element.
|
protected |
|
protecteddefault |
int64 sydevs::arraynd_base< T, ndims >::size | ( | ) | const |
Returns the total number of elements.
std::array< int64, ndims > sydevs::arraynd_base< T, ndims >::strides | ( | ) | const |
Returns the number of element-size steps in memory between successive elements for each dimension.
|
staticprotected |
|
staticprotected |
|
staticprotected |
bool sydevs::arraynd_base< T, ndims >::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.
For each element traversed in row-major order, func
is called with the indices
of the element and the element's value
. If func
returns true
, the traversal continues. If func
returns false
, the traversal is terminated.
func | The function to be called at every element. |
true
if the entire multidimensional array is traversed and func
returns true
at every element; false
otherwise.
|
friend |
|
friend |