libpnicore
|
template for a multi-dimensional array class More...
#include <mdarray.hpp>
Public Types | |
typedef STORAGE | storage_type |
type of the buffer object | |
typedef storage_type::value_type | value_type |
arrays element type | |
typedef IMAP | map_type |
index map type | |
typedef mdarray< storage_type, map_type, IPA > | array_type |
type of the array | |
typedef storage_type::iterator | iterator |
iterator type | |
typedef storage_type::const_iterator | const_iterator |
const iterator type | |
typedef storage_type::reverse_iterator | reverse_iterator |
reverse iterator | |
typedef storage_type::const_reverse_iterator | const_reverse_iterator |
const reverse iterator | |
typedef IPA | inplace_arithmetic |
inplace arithmetics type | |
typedef array_view< array_type > | view_type |
view type | |
typedef array_view< const array_type > | const_view_type |
const view type | |
typedef size_t | size_type |
type used for size | |
Public Member Functions | |
mdarray () | |
default constructor | |
mdarray (const map_type &map, const storage_type &s) | |
construct from map and storage More... | |
mdarray (map_type &&map, storage_type &&s) | |
move construct from map and storage More... | |
template<typename ATYPE > | |
mdarray (const array_view< ATYPE > &view) | |
constrcut from a view More... | |
template<typename... MDARGS> | |
mdarray (const mdarray< MDARGS...> &array) | |
construction from an other array More... | |
template<typename... MDARGS> | |
array_type & | operator= (const mdarray< MDARGS...> &array) |
assignment from a different array type More... | |
array_type & | operator= (const std::initializer_list< value_type > &l) |
assignment from an initializer list More... | |
const map_type & | map () const |
get index map More... | |
template<typename CTYPE > | |
CTYPE | shape () const |
shape to container More... | |
size_t | size () const |
get size of array More... | |
size_t | rank () const |
get number of dimensions More... | |
value_type & | operator[] (size_t i) |
get referece to element i More... | |
value_type | operator[] (size_t i) const |
get value at i More... | |
value_type & | at (size_t i) |
get value at i More... | |
value_type | at (size_t i) const |
get value at i More... | |
void | insert (size_t i, const value_type &value) |
insert value at index i More... | |
template<typename CTYPE , typename = typename enable_element_cont<CTYPE>::type> | |
value_type & | operator() (const CTYPE &index) |
return element reference More... | |
template<typename CTYPE , typename = typename enable_element_cont<CTYPE>::type> | |
value_type | operator() (const CTYPE &index) const |
return element value More... | |
template<typename CTYPE , typename = typename enable_view_cont<CTYPE>::type> | |
array_view< const array_type > | operator() (const CTYPE &slices) const |
return array view More... | |
template<typename CTYPE , typename = typename enable_view_cont<CTYPE>::type> | |
array_view< array_type > | operator() (const CTYPE &slices) |
return array view More... | |
template<typename... ITYPES, typename = typename enable_valid_index<ITYPES...>::type> | |
view_type_trait< array_type, ITYPES...>::type | operator() (ITYPES...indexes) |
multiindex access More... | |
template<typename... ITYPES, typename = typename enable_valid_index<ITYPES...>::type> | |
view_type_trait< const array_type, ITYPES...> ::const_type | operator() (ITYPES...indexes) const |
multiindex access More... | |
const value_type * | data () const |
return const pointer More... | |
value_type * | data () |
return pointer More... | |
value_type & | front () |
reference to first element More... | |
value_type | front () const |
value of first element More... | |
value_type & | back () |
reference to last element More... | |
value_type | back () const |
value of last element More... | |
iterator | begin () |
iterator to first element More... | |
iterator | end () |
iterator to last element More... | |
const_iterator | begin () const |
const-iterator to first element More... | |
const_iterator | end () const |
const-iterator to last element More... | |
reverse_iterator | rbegin () |
return reverse iterator to last element | |
const_reverse_iterator | rbegin () const |
return const reverse iterator to last element | |
reverse_iterator | rend () |
return reverse iterator to 0-1 element | |
const_reverse_iterator | rend () const |
return const reverse iterator to 0-1 element | |
array_type & | operator+= (value_type s) |
unary addition of a scalar More... | |
template<typename ATYPE > | |
array_type & | operator+= (const ATYPE &v) |
unary addition of an array More... | |
array_type & | operator-= (value_type s) |
unary subtraction of a scalar More... | |
template<typename ATYPE > | |
array_type & | operator-= (const ATYPE &v) |
unary subtraction of an array More... | |
array_type & | operator*= (value_type s) |
unary multiplication of a scalar More... | |
template<typename ATYPE > | |
array_type & | operator*= (const ATYPE &v) |
unary multiplication of an array More... | |
array_type & | operator/= (value_type s) |
unary division of a scalar More... | |
template<typename ATYPE > | |
array_type & | operator/= (const ATYPE &v) |
unary division of an array More... | |
Static Public Member Functions | |
template<typename... ARGS> | |
static array_type | create (ARGS...arguments) |
generic construction function More... | |
template<typename T1 , typename T2 > | |
static array_type | create (const std::initializer_list< T1 > &l1, const std::initializer_list< T2 > &l2) |
construction from initializer list More... | |
Static Public Attributes | |
static const type_id_t | type_id |
type ID of the element type More... | |
Private Attributes | |
IMAP | _imap |
Index map of the array. | |
STORAGE | _data |
instance of STORAGE | |
STORAGE | storage object to use to keep the data |
IMAP | the index map |
IPA | unary (inplace) arithmetics implementation |
|
inlineexplicit |
Construct an array from an index map and a storage.
map | the index map instance |
s | array storage |
|
inlineexplicit |
Move construct an array from rvalue refernces to an index map and a storage.
map | rvalue reference to the index map |
s | rvalue reference to the storage |
|
inlineexplicit |
This constructor creates a new array from an array view instance. The resulting array object has the same shape as the view.
ATYPE | storage type of the view |
view | reference to the view |
|
inlineexplicit |
This constructor can be used for instance along with expression templates in order to construct an array from an expression.
MDARGS | template parameters of mdarray |
array | reference to the source array |
|
inline |
Return a reference to the value at linear index i. This method performs index checking.
index_error | if i exceeds array size |
i | linear index of element |
|
inline |
Return the value of element i. This method performs index checking.
index_error | if i exceeds array size |
i | linear index of element |
|
inline |
Return a reference to the last element in the linear view of the array.
|
inline |
Return the value of the last element in the linear view of the array.
|
inline |
Returns a non-const iterator to the first element in the array.
|
inline |
Returns a const-iterator to the first element in the array.
|
inlinestatic |
This function can be used for easy array construction. It uses the array_factory template in the background.
ARGS | variadic argument types |
arguments | variadic argument list |
|
inlinestatic |
This version of the static create function uses an initializer list. The first initializer list holds shape information while the second holds the data which will be stored in the array.
T1 | element type of shape list |
T2 | element type of data list |
l1 | instance of shape list |
l2 | instance of data list |
|
inline |
Return a const pointer to the data stored in the array.
|
inline |
Return a pointer to the data stored in the array.
|
inline |
Returns a non-const iterator to the last element in the array.
|
inline |
Returns a const-iterator to the last element in the array.
|
inline |
Return a reference to the first element in the linear view of the array.
|
inline |
Return the value of the first element in the linear view of the array.
|
inline |
Insert value at index i.
index_error | if i exceeds the size of the array |
i | linear index of the element |
value | the value to store at index i |
|
inline |
Returns a const reference to the index map of the array.
|
inline |
Returns the reference to a single elemnt of the array determined by a multidimensional index of unsigned integers stored in a container of type CTYPE. This method performs no range checking.
CTYPE | index container type |
index | reference to index container |
|
inline |
Returns the value of a single elemnt of the array determined by a multidimensional index of unsigned integers stored in a container of type CTYPE. This method performs no range checking.
CTYPE | index container type |
index | reference to index container |
|
inline |
Return a view on the array determined by a set of slices stored in a container type CTYPE.
CTYPE | slice container type |
slices | reference to the container |
|
inline |
Return a view on the array determined by a set of slices stored in a container type CTYPE.
CTYPE | slice container type |
slices | reference to the container |
|
inline |
The () operator allows multindex access to the data stored in the array. Like the [] operator it does not perform any checks of index ranges and should thus be used with care. However, due to the missign checks it is extremely fast. If index checking is required have a look the corresponding at() member function.
ITYPES | index types |
indexes | list of index values |
|
inline |
The () operator allows multindex access to the data stored in the array. Like the [] operator it does not perform any checks of index ranges and should thus be used with care. However, due to the missign checks it is extremely fast. If index checking is required have a look the corresponding at() member function.
ITYPES | index types |
indexes | list of index values |
|
inline |
!
s | the scalar value to multiply with |
|
inline |
!
ATYPE | type of the array to multiply |
v | reference to the array to multiply |
|
inline |
!
s | the scalar value to add |
|
inline |
!
ATYPE | type of the array to add |
v | reference to the array to add |
|
inline |
!
s | the scalar value to subtract |
|
inline |
!
ATYPE | type of the array to subtract |
v | reference to the array to subtract |
|
inline |
!
s | the scalar value to divide by |
|
inline |
!
ATYPE | type of the array to divide by |
v | reference to the array to divide by |
|
inline |
Assign the data from a different array type to this one.
size_mismatch_error | if array sizes do not match |
shape_mismatch_error | if shapes do not match |
MDARGS | template parameters of the source type |
array | reference to the source array |
|
inline |
Assigns the values given by an initializer list to an allocated array. If the number of elements in the list does not match the number of elements in the array an exception is thrown.
size_mismatch_error | if list size and array size do not match |
l | reference to an initializer list |
|
inline |
Returns a reference to the element at linear index i. No index checking is done! Thus use this operator with care.
i | linear index |
|
inline |
Returns the value of the element at the linar array index i. No index checking is done! Thus use this operator with care.
i | linear index of the element |
|
inline |
Returns the number of dimensions of the array.
|
inline |
This returns a container of type CTYPE with the number of elements stored in the array.
CTYPE | container type |
|
inline |
Returns the total number of elements stored in the array.
|
static |