Domi
Multi-dimensional, distributed data structures
|
Memory-safe, reference-counted, templated, multi-dimensional array class. More...
#include <Domi_MDArrayRCP.hpp>
Public Types | |
Public types | |
typedef T | value_type |
Value type. | |
typedef T * | pointer |
Pointer type. | |
typedef const T * | const_pointer |
Const pointer type. | |
typedef T & | reference |
Reference type. | |
typedef const T & | const_reference |
Const reference type. | |
Public Member Functions | |
Constructors, Destructor, Initializers | |
MDArrayRCP (Teuchos::ENull null_arg=Teuchos::null) | |
Default constructor. More... | |
MDArrayRCP (const Teuchos::ArrayView< T > &array, const Teuchos::ArrayView< dim_type > &dims, Layout layout=DEFAULT_ORDER) | |
Constructor with Teuchos::ArrayView source, dimensions, and optional storage order flag. More... | |
MDArrayRCP (const Teuchos::ArrayView< dim_type > &dims, const_reference val=T(), Layout layout=DEFAULT_ORDER) | |
Constructor with dimensions, default value and optional storage order flag. More... | |
MDArrayRCP (const Teuchos::ArrayView< dim_type > &dims, Layout layout) | |
Constructor with dimensions and storage order flag. More... | |
MDArrayRCP (const Teuchos::ArrayView< dim_type > &dims, const Teuchos::ArrayView< size_type > &strides, T *data, Layout layout=DEFAULT_ORDER) | |
Low-level view constructor. More... | |
MDArrayRCP (const MDArrayRCP< T > &r_ptr) | |
Shallow copy constructor. More... | |
MDArrayRCP (const MDArrayView< T > &source) | |
Deep copy constructor. More... | |
~MDArrayRCP () | |
Destructor. | |
MDArrayRCP< T > & | operator= (const MDArrayRCP< T > &r_ptr) |
Assignment operator. More... | |
Attribute accessor methods | |
int | numDims () const |
Return the number of dimensions. | |
const Teuchos::Array< dim_type > & | dimensions () const |
Return the array of dimensions. | |
dim_type | dimension (int axis) const |
Return the dimension of the given axis. More... | |
size_type | size () const |
Return the total size of the MDArrayRCP | |
const Teuchos::Array< size_type > & | strides () const |
Return the indexing strides. | |
const Teuchos::ArrayRCP< T > & | arrayRCP () const |
Return the underlying Teuchos::ArrayRCP | |
const Layout | layout () const |
Return the storage order. | |
Object/pointer access functions | |
bool | is_null () const |
Return true if the underlying pointer is null. | |
pointer | operator-> () const |
Pointer -> access to members of underlying data buffer. | |
reference | operator* () |
Dereference the underlying data buffer. | |
pointer | get () const |
Get the raw C++ pointer to the underlying data buffer. | |
Conversions to MDArrayView | |
MDArrayView< T > | mdArrayView () |
Perform an explicit conversion to a non-const MDArrayView<T> | |
const MDArrayView< T > | mdArrayView () const |
Perform an explicit conversion to a const MDArrayView<T> | |
MDArrayView< const T > | mdArrayViewConst () |
Perform an explicit conversion to a non-const MDArrayView<const T> | |
const MDArrayView< const T > | mdArrayViewConst () const |
Perform an explicit conversion to a const MDArrayView<const T> | |
operator MDArrayView< T > () const | |
Perform an implicit conversion to a non-const MDArrayView | |
operator MDArrayView< const T > () const | |
Perform an implicit conversion to a const MDArrayView | |
Indexing operators that return <tt>MDArrayView</tt>s | |
MDArrayView< T > | operator[] (dim_type i) |
Sub-array access operator. The returned MDArrayView object will have one fewer dimensions than the calling MDArrayRCP . More... | |
const MDArrayView< T > | operator[] (dim_type i) const |
Sub-array const access operator. The returned MDArrayView object will have one fewer dimensions than the calling MDArrayRCP . More... | |
MDArrayView< T > | operator[] (Slice s) |
Sub-array access operator. The returned MDArrayView object will have the same number of dimensions as the calling MDArrayRCP . More... | |
const MDArrayView< T > | operator[] (Slice s) const |
Sub-array const access operator. The returned MDArrayView object will have the same number of dimensions as the calling MDArrayRCP . More... | |
MDArrayView< T > | operator() () |
Conversion to MDArrayView | |
const MDArrayView< T > | operator() () const |
Conversion to const MDArrayView | |
Indexing operators that return a reference to a single array element | |
T & | operator() (dim_type i) |
Non-const 1D element access operator. More... | |
T & | operator() (dim_type i, dim_type j) |
Non-const 2D element access operator. More... | |
T & | operator() (dim_type i, dim_type j, dim_type k) |
Non-const 3D element access operator. More... | |
T & | operator() (dim_type i, dim_type j, dim_type k, dim_type m) |
Non-const 4D element access operator. More... | |
T & | operator() (dim_type i, dim_type j, dim_type k, dim_type m, dim_type n) |
Non-const 5D element access operator. More... | |
T & | operator() (dim_type i, dim_type j, dim_type k, dim_type m, dim_type n, dim_type p,...) |
Non-const 6D and higher element access operator. More... | |
const T & | operator() (dim_type i) const |
Const 1D element access operator. More... | |
const T & | operator() (dim_type i, dim_type j) const |
Const 2D element access operator. More... | |
const T & | operator() (dim_type i, dim_type j, dim_type k) const |
Const 3D element access operator. More... | |
const T & | operator() (dim_type i, dim_type j, dim_type k, dim_type m) const |
Const 4D element access operator. More... | |
const T & | operator() (dim_type i, dim_type j, dim_type k, dim_type m, dim_type n) const |
Const 5D element access operator. More... | |
const T & | operator() (dim_type i, dim_type j, dim_type k, dim_type m, dim_type n, dim_type p,...) const |
Const 6D and higher element access operator. More... | |
Friends | |
Non-member operators and functions | |
template<typename T2 > | |
bool | operator== (const MDArrayRCP< T2 > &a1, const MDArrayRCP< T2 > &a2) |
Equality operator. | |
template<typename T2 > | |
bool | operator== (const MDArray< T2 > &a1, const MDArrayRCP< T2 > &a2) |
MDArray/MDArrayRCP equality operator. | |
template<typename T2 > | |
bool | operator== (const MDArrayRCP< T2 > &a1, const MDArray< T2 > &a2) |
MDArrayRCP/MDArray equality operator. | |
template<typename T2 > | |
bool | operator== (const MDArrayRCP< T2 > &a1, const MDArrayView< T2 > &a2) |
MDArrayRCP/MDArrayView equality operator. | |
template<typename T2 > | |
bool | operator== (const MDArrayView< T2 > &a1, const MDArrayRCP< T2 > &a2) |
MDArrayView/MDArrayRCP equality operator. | |
template<typename T2 > | |
bool | operator!= (const MDArrayRCP< T2 > &a1, const MDArrayRCP< T2 > &a2) |
Inequality operator. | |
template<typename T2 > | |
bool | operator!= (const MDArray< T2 > &a1, const MDArrayRCP< T2 > &a2) |
MDArray/MDArrayRCP inequality operator. | |
template<typename T2 > | |
bool | operator!= (const MDArrayRCP< T2 > &a1, const MDArray< T2 > &a2) |
MDArrayRCP/MDArray inequality operator. | |
template<typename T2 > | |
bool | operator!= (const MDArrayRCP< T2 > &a1, const MDArrayView< T2 > &a2) |
MDArrayRCP/MDArrayView inequality operator. | |
template<typename T2 > | |
bool | operator!= (const MDArrayView< T2 > &a1, const MDArrayRCP< T2 > &a2) |
MDArrayView/MDArrayRCP inequality operator. | |
template<typename T2 > | |
std::ostream & | operator<< (std::ostream &os, const MDArrayRCP< T2 > &a) |
Stream output operator. | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
bool | operator== (const MDArrayRCP< T > &a1, const MDArrayRCP< T > &a2) |
Equality operator. | |
template<typename T > | |
bool | operator== (const MDArray< T > &a1, const MDArrayRCP< T > &a2) |
MDArray/MDArrayRCP equality operator. | |
template<typename T > | |
bool | operator== (const MDArrayRCP< T > &a1, const MDArray< T > &a2) |
MDArrayRCP/MDArray equality operator. | |
template<typename T > | |
bool | operator== (const MDArrayView< T > &a1, const MDArrayRCP< T > &a2) |
MDArrayView/MDArrayRCP equality operator. | |
template<typename T > | |
bool | operator== (const MDArrayRCP< T > &a1, const MDArrayView< T > &a2) |
MDArrayRCP/MDArrayView equality operator. | |
template<typename T > | |
bool | operator!= (const MDArrayRCP< T > &a1, const MDArrayRCP< T > &a2) |
Inequality operator. | |
template<typename T > | |
bool | operator!= (const MDArray< T > &a1, const MDArrayRCP< T > &a2) |
MDArray/MDArrayRCP inequality operator. | |
template<typename T > | |
bool | operator!= (const MDArrayView< T > &a1, const MDArrayRCP< T > &a2) |
MDArrayView/MDArrayRCP inequality operator. | |
template<typename T > | |
bool | operator!= (const MDArrayRCP< T > &a1, const MDArrayView< T > &a2) |
MDArrayRCP/MDArrayView inequality operator. | |
Iterator classes and methods | |
typedef MDIterator< MDArrayRCP < T > > | iterator |
typedef MDIterator< MDArrayRCP < const T > > | const_iterator |
typedef MDRevIterator < MDArrayRCP< T > > | reverse_iterator |
typedef MDRevIterator < MDArrayRCP< const T > > | const_reverse_iterator |
class | MDIterator< MDArrayRCP< T > > |
class | MDIterator< MDArrayRCP< const T > > |
class | MDRevIterator< MDArrayRCP< T > > |
class | MDRevIterator< MDArrayRCP< const T > > |
iterator | begin () |
Return the beginning iterator. | |
iterator | end () |
Return the ending iterator. | |
const_iterator | begin () const |
Return the beginning const_iterator. | |
const_iterator | end () const |
Return the ending const_iterator. | |
const_iterator | cbegin () const |
Return the beginning const_iterator. | |
const_iterator | cend () const |
Return the ending const_iterator. | |
reverse_iterator | rbegin () |
Return the beginning reverse_iterator. | |
reverse_iterator | rend () |
Return the ending reverse_iterator. | |
const_reverse_iterator | crbegin () const |
Return the beginning const_reverse_iterator. | |
const_reverse_iterator | crend () const |
Return the ending const_reverse_iterator. | |
Teuchos::Array-like and std::vector-like methods | |
void | assign (const_reference value) |
Assign a value to all elements of the MDArrayRCP More... | |
reference | at (dim_type i,...) |
Non-const single element access method with bounds checking. More... | |
const_reference | at (dim_type i,...) const |
Const single element access method with bounds checking. More... | |
size_type | capacity () const |
Return the capacity of the underlying Teuchos::ArrayRCP | |
void | clear () |
Clear the MDArrayRCP | |
bool | empty () const |
Return whether the MDArrayRCP is empty. | |
size_type | max_size () const |
Return the maximum allowable size for the MDArrayRCP | |
void | resize (const Teuchos::ArrayView< dim_type > &dims) |
Resize the MDArrayRCP based on the given dimensions. More... | |
std::string | toString () const |
Convert the MDArrayRCP to a string representation. | |
const_pointer | getRawPtr () const |
Return a const raw pointer to the beginning of the MDArrayRCP or NULL if unsized. | |
pointer | getRawPtr () |
Return a raw pointer to the beginning of the MDArrayRCP or NULL if unsized. | |
static bool | hasBoundsChecking () |
Return true if MDArrayRCP has been compiled with bounds checking on. | |
Memory-safe, reference-counted, templated, multi-dimensional array class.
MDArrayRCP
is a reference counted class similar to Teuchos::ArrayRCP
, except that it interprets its data buffer as a multi-dimensional array instead of a one-dimensional array.
|
inline |
Default constructor.
null_arg | [in] Optional null pointer specifier |
|
inline |
Constructor with Teuchos::ArrayView
source, dimensions, and optional storage order flag.
array | [in] Teuchos::ArrayView of data buffer |
dims | [in] An array that defines the lengths of each dimension. The most convenient way to specify dimensions is with a Tuple returned by the non-member Teuchos::tuple<T>() function. |
layout | [in] Specifies the order data elements are stored in memory (default DEFAULT_ORDER) |
The MDArrayRCP
does not take ownership of the data buffer.
|
inlineexplicit |
Constructor with dimensions, default value and optional storage order flag.
dims | [in] An array that defines the lengths of each dimension. The most convenient way to specify dimensions is with a Tuple returned by the non-member Teuchos::tuple<T>() function. |
val | [in] Default array fill value |
layout | [in] Specifies the order data elements are stored in memory |
This constructor allocates new memory and takes ownership of it.
|
inlineexplicit |
Constructor with dimensions and storage order flag.
dims | [in] An array that defines the lengths of each dimension. The most convenient way to specify dimensions is with a Tuple returned by the non-member Teuchos::tuple<T>() function. |
layout | [in] Specifies the order data elements are stored in memory |
This constructor allocates new memory and takes ownership of it.
|
inlineexplicit |
Low-level view constructor.
dims | [in] An array that defines the lengths of each dimension. The most convenient way to specify dimensions is with a Tuple returned by the non-member Teuchos::tuple<T>() function. |
strides | [in] An array that defines the data strides of each dimension. The most convenient way to specify strides is with a Tuple returned by the non-member Teuchos::tuple<T>() function. |
data | [in] a pointer to the data buffer used by the MDArrayRCP. The MDArrayRCP will not take ownership of the data. |
layout | [in] Specifies the order data elements are stored in memory |
|
inline |
Shallow copy constructor.
r_ptr | [in] Source reference counted pointer |
Domi::MDArrayRCP< T >::MDArrayRCP | ( | const MDArrayView< T > & | source | ) |
Deep copy constructor.
source | [in] Source MDArrayView |
void Domi::MDArrayRCP< T >::assign | ( | const_reference | value | ) |
Assign a value to all elements of the MDArrayRCP
value | [in] The value to be assigned |
T & Domi::MDArrayRCP< T >::at | ( | dim_type | i, |
... | |||
) |
Non-const single element access method with bounds checking.
i,... | [in] Indexes representing the location of the single element of the MDArrayRCP to be accessed. Note that this method assumes that the user will provide the same number of arguments as the number of dimensions of the MDArrayRCP . |
const T & Domi::MDArrayRCP< T >::at | ( | dim_type | i, |
... | |||
) | const |
Const single element access method with bounds checking.
i,... | [in] Indexes representing the location of the single element of the MDArrayRCP to be accessed. Note that this method assumes that the user will provide the same number of arguments as the number of dimensions of the MDArrayRCP . |
|
inline |
Return the dimension of the given axis.
axis | [in] The axis being queried (0 for the first axis, 1 for the second axis, and so forth) |
|
inline |
Non-const 1D element access operator.
i | [in] 1D index. |
This operator should only be used with a 1D MDArrayRCP
. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is not 1D, an exception will be thrown.
|
inline |
Non-const 2D element access operator.
i | [in] first 2D index. |
j | [in] second 2D index. |
This operator should only be used with a 2D MDArrayRCP
. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is not 2D, an exception will be thrown.
|
inline |
Non-const 3D element access operator.
i | [in] first 3D index. |
j | [in] second 3D index. |
k | [in] third 3D index. |
This operator should only be used with a 3D MDArrayRCP
. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is not 3D, an exception will be thrown.
|
inline |
Non-const 4D element access operator.
i | [in] first 4D index. |
j | [in] second 4D index. |
k | [in] third 4D index. |
m | [in] fourth 4D index. |
This operator should only be used with a 4D MDArrayRCP
. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is not 4D, an exception will be thrown.
|
inline |
Non-const 5D element access operator.
i | [in] first 5D index. |
j | [in] second 5D index. |
k | [in] third 5D index. |
m | [in] fourth 5D index. |
n | [in] fifth 5D index. |
This operator should only be used with a 5D MDArrayRCP
. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is not 5D, an exception will be thrown.
|
inline |
Non-const 6D and higher element access operator.
i | [in] first index. |
j | [in] second index. |
k | [in] third index. |
m | [in] fourth index. |
n | [in] fifth index. |
p | [in] sixth index. |
... | [in] seventh and higher indexes. |
This operator should only be used with a 6D and higher MDArrayRCP
s. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is less than 6D, an exception will be thrown.
|
inline |
Const 1D element access operator.
i | [in] 1D index. |
This operator should only be used with a 1D MDArrayRCP
. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is not 1D, an exception will be thrown.
|
inline |
Const 2D element access operator.
i | [in] first 2D index. |
j | [in] second 2D index. |
This operator should only be used with a 2D MDArrayRCP
. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is not 2D, an exception will be thrown.
|
inline |
Const 3D element access operator.
i | [in] first 3D index. |
j | [in] second 3D index. |
k | [in] third 3D index. |
This operator should only be used with a 3D MDArrayRCP
. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is not 3D, an exception will be thrown.
|
inline |
Const 4D element access operator.
i | [in] first 4D index. |
j | [in] second 4D index. |
k | [in] third 4D index. |
m | [in] fourth 4D index. |
This operator should only be used with a 4D MDArrayRCP
. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is not 4D, an exception will be thrown.
|
inline |
Const 5D element access operator.
i | [in] first 5D index. |
j | [in] second 5D index. |
k | [in] third 5D index. |
m | [in] fourth 5D index. |
n | [in] fifth 5D index. |
This operator should only be used with a 5D MDArrayRCP
. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is not 5D, an exception will be thrown.
|
inline |
Const 6D and higher element access operator.
i | [in] first index. |
j | [in] second index. |
k | [in] third index. |
m | [in] fourth index. |
n | [in] fifth index. |
p | [in] sixth index. |
... | [in] seventh and higher indexes. |
This operator should only be used with a 6D and higher MDArrayRCP
s. If HAVE_DOMI_ARRAY_BOUNDSCHECK is true and the MDArrayRCP
is less than 6D, an exception will be thrown.
|
inline |
Assignment operator.
r_ptr | [in] Source reference counted pointer |
MDArrayView< T > Domi::MDArrayRCP< T >::operator[] | ( | dim_type | i | ) |
Sub-array access operator. The returned MDArrayView
object will have one fewer dimensions than the calling MDArrayRCP
.
i | [in] Index of the desired sub-array. Note that to obtain expected behavior, you should always chain together n square bracket operators when referencing an n -dimensional MDArrayRCP . |
const MDArrayView< T > Domi::MDArrayRCP< T >::operator[] | ( | dim_type | i | ) | const |
Sub-array const access operator. The returned MDArrayView
object will have one fewer dimensions than the calling MDArrayRCP
.
i | [in] Index of the desired sub-array. Note that to obtain expected behavior, you should always chain together n square bracket operators when referencing an n -dimensional MDArrayRCP . |
MDArrayView< T > Domi::MDArrayRCP< T >::operator[] | ( | Slice | s | ) |
Sub-array access operator. The returned MDArrayView
object will have the same number of dimensions as the calling MDArrayRCP
.
s | [in] Slice representing the bounds of the desired sub-array. Note that to obtain expected behavior, you should always chain together n square bracket operators when referencing an n -dimensional MDArrayRCP . |
const MDArrayView< T > Domi::MDArrayRCP< T >::operator[] | ( | Slice | s | ) | const |
Sub-array const access operator. The returned MDArrayView
object will have the same number of dimensions as the calling MDArrayRCP
.
s | [in] Slice representing the bounds of the desired sub-array. Note that to obtain expected behavior, you should always chain together n square bracket operators when referencing an n -dimensional MDArrayRCP . |
void Domi::MDArrayRCP< T >::resize | ( | const Teuchos::ArrayView< dim_type > & | dims | ) |
Resize the MDArrayRCP
based on the given dimensions.
dims | [in] An array that defines the new lengths of each dimension. The most convenient way to specify dimensions is with a Tuple returned by the non-member Teuchos::tuple<T>() function. |