Multidimensional array API¶
mdarray¶
-
template <typename STORAGE, typename IMAP = dynamic_cindex_map, typename IPA = inplace_arithmetics>
classmdarray¶ template for a multi-dimensional array class
- Template Parameters
STORAGE: storage object to use to keep the dataIMAP: the index mapIPA: unary (inplace) arithmetics implementation
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 Functions
-
mdarray()¶ default constructor
-
mdarray(const map_type &map, const storage_type &s)¶ construct from map and storage
Construct an array from an index map and a storage.
- Parameters
map: the index map instances: array storage
-
mdarray(map_type &&map, storage_type &&s)¶ move construct from map and storage
Move construct an array from rvalue refernces to an index map and a storage.
- Parameters
map: rvalue reference to the index maps: rvalue reference to the storage
-
template <typename ATYPE>
mdarray(const array_view<ATYPE> &view)¶ constrcut from a view
This constructor creates a new array from an array view instance. The resulting array object has the same shape as the view.
- Template Parameters
ATYPE: storage type of the view
- Parameters
view: reference to the view
-
template <typename ... MDARGS>
mdarray(const mdarray<MDARGS...> &array)¶ construction from an other array
This constructor can be used for instance along with expression templates in order to construct an array from an expression.
- Template Parameters
MDARGS: template parameters of mdarray
- Parameters
array: reference to the source array
-
template <typename ... MDARGS>
array_type &operator=(const mdarray<MDARGS...> &array)¶ assignment from a different array type
Assign the data from a different array type to this one.
- Return
- reference to the updated array
- Exceptions
size_mismatch_error: if array sizes do not matchshape_mismatch_error: if shapes do not match
- Template Parameters
MDARGS: template parameters of the source type
- Parameters
array: reference to the source array
-
array_type &
operator=(const std::initializer_list<value_type> &l)¶ assignment from an initializer list
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.
- Return
- reference to the array
- Exceptions
size_mismatch_error: if list size and array size do not match
- Parameters
l: reference to an initializer list
-
const map_type &
map() const¶ get index map
Returns a const reference to the index map of the array.
- Return
- reference to index map
-
template <typename CTYPE>
CTYPEshape() const¶ shape to container
This returns a container of type CTYPE with the number of elements stored in the array.
- Return
- instance of CTYPE with shape data
- Template Parameters
CTYPE: container type
-
size_t
size() const¶ get size of array
Returns the total number of elements stored in the array.
- Return
- total number of elements
-
size_t
rank() const¶ get number of dimensions
Returns the number of dimensions of the array.
- Return
- number of dimensions
-
value_type &
operator[](size_t i)¶ get referece to element i
Returns a reference to the element at linear index i. No index checking is done! Thus use this operator with care.
- Return
- reference to the element at linear index i
- Parameters
i: linear index
-
value_type
operator[](size_t i) const¶ get value at i
Returns the value of the element at the linar array index i. No index checking is done! Thus use this operator with care.
- Return
- value of the element at linear index i
- Parameters
i: linear index of the element
-
value_type &
at(size_t i)¶ get value at i
Return a reference to the value at linear index i. This method performs index checking.
- Return
- reference to the value at i
- Exceptions
index_error: if i exceeds array size
- Parameters
i: linear index of element
-
value_type
at(size_t i) const¶ get value at i
Return the value of element i. This method performs index checking.
- Return
- value at i
- Exceptions
index_error: if i exceeds array size
- Parameters
i: linear index of element
-
void
insert(size_t i, const value_type &value)¶ insert value at index i
Insert value at index i.
- Exceptions
index_error: if i exceeds the size of the array
- Parameters
i: linear index of the elementvalue: the value to store at index i
-
template <typename CTYPE, typename = typename enable_element_cont<CTYPE>::type>
value_type &operator()(const CTYPE &index)¶ return element reference
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.
- Return
- reference to the element
- Template Parameters
CTYPE: index container type
- Parameters
index: reference to index container
-
template <typename CTYPE, typename = typename enable_element_cont<CTYPE>::type>
value_typeoperator()(const CTYPE &index) const¶ return element value
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.
- Return
- value of the element
- Template Parameters
CTYPE: index container type
- Parameters
index: reference to index container
-
template <typename CTYPE, typename = typename enable_view_cont<CTYPE>::type>
array_view<const array_type>operator()(const CTYPE &slices) const return array view
Return a view on the array determined by a set of slices stored in a container type CTYPE.
- Return
- array_view instance
- Template Parameters
CTYPE: slice container type
- Parameters
slices: reference to the container
-
template <typename CTYPE, typename = typename enable_view_cont<CTYPE>::type>
array_view<array_type>operator()(const CTYPE &slices) return array view
Return a view on the array determined by a set of slices stored in a container type CTYPE.
- Return
- array_view instance
- Template Parameters
CTYPE: slice container type
- Parameters
slices: reference to the container
-
template <typename... ITYPES, typename = typename enable_valid_index<ITYPES...>::type>
view_type_trait<array_type, ITYPES...>::typeoperator()(ITYPES... indexes) multiindex access
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.
- Return
- reference to the value at the given index
- Template Parameters
ITYPES: index types
- Parameters
indexes: list of index values
-
template <typename... ITYPES, typename = typename enable_valid_index<ITYPES...>::type>
view_type_trait<const array_type, ITYPES...>::const_typeoperator()(ITYPES... indexes) const multiindex access
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.
- Return
- value at the given index
- Template Parameters
ITYPES: index types
- Parameters
indexes: list of index values
-
const value_type *
data() const¶ return const pointer
Return a const pointer to the data stored in the array.
- Return
- pointer to data
-
value_type *
data()¶ return pointer
Return a pointer to the data stored in the array.
- Return
- pointer to data
-
value_type &
front()¶ reference to first element
Return a reference to the first element in the linear view of the array.
- Return
- reference to first element
-
value_type
front() const¶ value of first element
Return the value of the first element in the linear view of the array.
- Return
- value of the first element
-
value_type &
back()¶ reference to last element
Return a reference to the last element in the linear view of the array.
- Return
- reference to last element
-
value_type
back() const¶ value of last element
Return the value of the last element in the linear view of the array.
- Return
- value of last element
-
iterator
begin()¶ iterator to first element
Returns a non-const iterator to the first element in the array.
- Return
- iterator to first element
-
iterator
end()¶ iterator to last element
Returns a non-const iterator to the last element in the array.
- Return
- iterator to last element
-
const_iterator
begin() const¶ const-iterator to first element
Returns a const-iterator to the first element in the array.
- Return
- iterator to first element
-
const_iterator
end() const¶ const-iterator to last element
Returns a const-iterator to the last element in the array.
- Return
- iterator to last element
-
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
!array_type a = ...; array_type::value_type s = ...; a += s;
- Return
- array reference
- Parameters
s: the scalar value to add
-
template <typename ATYPE>
array_type &operator+=(const ATYPE &v)¶ unary addition of an array
!array_type1 a = ...; array_tyep2 b = ...; a += b;
- Return
- reference to the original array
- Template Parameters
ATYPE: type of the array to add
- Parameters
v: reference to the array to add
-
array_type &
operator-=(value_type s)¶ unary subtraction of a scalar
!array_type a = ...; array_type::value_type s = ...; a -= s;
- Return
- array reference
- Parameters
s: the scalar value to subtract
-
template <typename ATYPE>
array_type &operator-=(const ATYPE &v)¶ unary subtraction of an array
!array_type1 a = ...; array_tyep2 b = ...; a -= b;
- Return
- reference to the original array
- Template Parameters
ATYPE: type of the array to subtract
- Parameters
v: reference to the array to subtract
-
array_type &
operator*=(value_type s)¶ unary multiplication of a scalar
!array_type a = ...; array_type::value_type s = ...; a *= s;
- Return
- array reference
- Parameters
s: the scalar value to multiply with
-
template <typename ATYPE>
array_type &operator*=(const ATYPE &v)¶ unary multiplication of an array
!array_type1 a = ...; array_tyep2 b = ...; a *= b;
- Return
- reference to the original array
- Template Parameters
ATYPE: type of the array to multiply
- Parameters
v: reference to the array to multiply
-
array_type &
operator/=(value_type s)¶ unary division of a scalar
!array_type a = ...; array_type::value_type s = ...; a /= s;
- Return
- array reference
- Parameters
s: the scalar value to divide by
-
template <typename ATYPE>
array_type &operator/=(const ATYPE &v)¶ unary division of an array
!array_type1 a = ...; array_tyep2 b = ...; a /= b;
- Return
- reference to the original array
- Template Parameters
ATYPE: type of the array to divide by
- Parameters
v: reference to the array to divide by
Public Static Functions
-
template <typename ... ARGS>
static array_typecreate(ARGS... arguments)¶ generic construction function
This function can be used for easy array construction. It uses the array_factory template in the background.
- Return
- array instance
- Template Parameters
ARGS: variadic argument types
- Parameters
arguments: variadic argument list
-
template <typename T1, typename T2>
static array_typecreate(const std::initializer_list<T1> &l1, const std::initializer_list<T2> &l2)¶ construction from initializer list
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.
- Return
- instance of array_type
- Template Parameters
T1: element type of shape listT2: element type of data list
- Parameters
l1: instance of shape listl2: instance of data list
Public Static Attributes
-
constexpr type_id_t
type_id= type_id_map<value_type>::type_id¶ type ID of the element type
Operators¶
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator==” with arguments (const mdarray< STORAGE, IMAP, IPA > &, const mdarray< STORAGE, IMAP, IPA > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT bool pni::core::operator==(const complex128&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator==(const complex128&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator==(const complex32&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator==(const complex32&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator==(const complex64&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator==(const complex64&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator==(const none&, const none&)
- PNICORE_EXPORT bool pni::core::operator==(const slice&, const slice&)
- template <typename ATYPE>
bool pni::core::operator==(const array_view<ATYPE>&, const array_view<ATYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
bool pni::core::operator==(const mdarray<STORAGE, IMAP, IPA>&, const mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
bool pni::core::operator==(const scalar<T>&, const scalar<T>&)
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator!=” with arguments (const mdarray< STORAGE, IMAP, IPA > &, const mdarray< STORAGE, IMAP, IPA > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT bool pni::core::operator!=(const complex128&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex128&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex32&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex32&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex64&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex64&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator!=(const none&, const none&)
- PNICORE_EXPORT bool pni::core::operator!=(const slice&, const slice&)
- template <typename ATYPE>
bool pni::core::operator!=(const array_view<ATYPE>&, const array_view<ATYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
bool pni::core::operator!=(const mdarray<STORAGE, IMAP, IPA>&, const mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
bool pni::core::operator!=(const scalar<T>&, const scalar<T>&)
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator>>” with arguments (std::istream &, mdarray< STORAGE, IMAP, IPA > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT std::istream &pni::core::operator>>(std::istream&, bool_t&)
- PNICORE_EXPORT std::istream &pni::core::operator>>(std::istream&, none&)
- template <typename ATYPE>
std::istream &pni::core::operator>>(std::istream&, array_view<ATYPE>&)
- template <typename NTYPE>
std::istream &pni::core::operator>>(std::istream&, binary_t<NTYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
std::istream &pni::core::operator>>(std::istream&, mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
std::istream &pni::core::operator>>(std::istream&, scalar<T>&)
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator<<” with arguments (std::ostream &, const mdarray< STORAGE, IMAP, IPA > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const bool_t&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const exception_record&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const none&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const slice&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const type_id_t&)
- std::ostream &pni::core::operator<<(std::ostream&, const array_selection&)
- std::ostream &pni::core::operator<<(std::ostream&, const benchmark_result&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_args&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_argument_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_help_request&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_option_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const configuration&)
- std::ostream &pni::core::operator<<(std::ostream&, const exception&)
- std::ostream &pni::core::operator<<(std::ostream&, const file_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const index_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const iterator_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const key_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const memory_allocation_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const memory_not_allocated_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const not_implemented_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const range_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const shape_mismatch_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const size_mismatch_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const type_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const value_error&)
- template <typename ATYPE>
std::ostream &pni::core::operator<<(std::ostream&, const array_view<ATYPE>&)
- template <typename NTYPE>
std::ostream &pni::core::operator<<(std::ostream&, const binary_t<NTYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
std::ostream &pni::core::operator<<(std::ostream&, const mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
std::ostream &pni::core::operator<<(std::ostream&, const scalar<T>&)
array_view¶
-
template <typename ATYPE>
classarray_view¶ provides a view on a part of an array
The ArrayView class provides a view on the part of an array. No new memory is allocated. An array view can be obtained from an array using the () operator.
darray<float32> a(std::vector<size_t>{3,4,10}); //create a (4,10) view from the above array auto view = a(1,slice{0,4},Slice{0,10}); //the view can now be used like any other array - however, no new //memory isallocated. //create an array from the view darray<float32> roi(view.shape<std::vector<size_t> >(), darray<float32>::storage_type(view));
- Template Parameters
ATYPE: array type for the view
Public Types
-
template<>
usingstorage_type= ATYPE¶ storage type
-
template<>
usingvalue_type= typename ATYPE::value_type¶ type of the data values
-
template<>
usingarray_type= array_view<storage_type>¶ type of the view
shared pointer type
-
template<>
usingunique_ptr= std::unique_ptr<array_type>¶ unique pointer type
-
template<>
usingiterator= container_iterator<array_type>¶ iterator type
-
template<>
usingconst_iterator= container_iterator<const array_type>¶ const iterator type
-
template<>
usingview_type= array_view<array_type>¶ view type
-
template<>
usingindex_type= std::vector<size_t>¶ index type
-
template<>
usinginplace_arithmetic= typename ATYPE::inplace_arithmetic¶ inplace arithetic type
-
template<>
usingmap_type= index_map<index_type, typename ATYPE::map_type::implementation_type>¶ map type
Public Functions
-
array_view(storage_type &a, const array_selection &s)¶ constructor
Constructs a new ArrayView from an existing array and some additional information.
- Parameters
a: reference to the original arrays: selection object defining the description dimension
-
array_view(storage_type &a, array_selection &&s)¶ constructor
This constructor accepts an rvalue reference for the selection. In some cases this might be more efficient than copy construction.
- Parameters
a: reference to the original arrays: rvalue reference to the selection object
-
array_view(const array_type &c)¶ copy constructor
-
array_view(array_type &&c)¶ move constructor
-
template <typename ETYPE>
array_type &operator=(const ETYPE &e)¶ copy assignment operator
-
array_type &
operator=(array_type &&a)¶ move assignment operator
-
template <typename CTYPE, typename = typename enable_element_cont<CTYPE>::type>
value_type &operator()(const CTYPE &index)¶ access with container index
Using a container object to hold the multidimensional indices to access view data.
- Return
- reference to value at index
- Exceptions
shape_mismatch_error: if size of container does not match view rank
- Template Parameters
CTYPE: container type for index values
- Parameters
index: container with multidimensional index
-
template <typename CTYPE, typename = typename enable_element_cont<CTYPE>::type>
value_typeoperator()(const CTYPE &index) const¶ access with container index
Using a container object to hold the multidimensional indices to access view data.
- Return
- value at index
- Exceptions
shape_mismatch_error: if size of container does not match view rank
- Template Parameters
CTYPE: container type for index values
- Parameters
index: container with multidimensional index
-
template <typename ... ITypes>
value_type &operator()(ITypes... indices)¶ multidimensional access to data
() operator allows access to the data using a multidimensional index represented by the arguments of the operator.
! This works essentially the same as for the Array template.darray<Float32> data({100,200,100}); auto view = data(slice(50,75),slice(0,200),slice(25,41)); std::cout<<view(3,34,10)<<std::endl;
- Return
- reference to the value at multidimensional index
- Template Parameters
ITypes: index types
- Parameters
indices: instances of ITypes determining the index
-
template <typename ... ITypes>
value_typeoperator()(ITypes... indices) const¶ multidimensional access to data
() operator allows access to the data using a multidimensional index represented by the arguments of the operator.
! This works essentially the same as for the Array template.darray<float32> data({100,200,100}); auto view = data(slice(50,75),slice(0,200),slice(25,41)); std::cout<<view(3,34,10)<<std::endl;
- Return
- value at multidimensional index
- Template Parameters
ITypes: index types
- Parameters
indices: instances of ITypes determining the multidimensional index
-
template <typename CTYPE>
CTYPEshape() const¶ get shape of the view
This returns the shape of the array view. This shape includes only those dimensions where the number of elements along the original array is not equal 1.
- Return
- Shape object
-
value_type &
operator[](size_t i)¶ linearzed access
Provides access to the linearized data. With this operator linear access is provided to the elements of the view.
- Return
- reference to the value at index i
- Exceptions
memory_access_error: if some of the involved objects is not allocated
- Parameters
i: linear index of the element
-
value_type
operator[](size_t i) const¶ linearized access
Provides const access to the linearized data. With this operator linear access is provided to the elements of the view.
- Return
- value at index i
- Exceptions
memory_access_error: if some of the involved objects is not allocated
- Parameters
i: linear index of the element
-
const value_type *
data() const¶ get pointer to data
This method returns a pointer to the storage covered by the view. However, this is only possible if the selection on which the view is passed is contiguous. In the case of a non contiguous view an exception will be thrown.
- Return
- const pointer to data
- Exceptions
shape_mismatch_error: if selection not contiguous
-
value_type *
data()¶ get pointer to data
This method returns a pointer to the storage covered by the view. However, this is only possible if the selection on which the view is passed is contiguous. In the case of a non contiguous view an exception will be thrown.
- Return
- const pointer to data
- Exceptions
shape_mismatch_error: if selection not contiguous
-
value_type &
at(size_t i)¶ get value at index i
Return a reference to the element at linear index i within the view. Unlike the [] operators this member function will throw an exception if the index exceeds the size of the view.
- Return
- reference to the element at index i
- Exceptions
index_error: in case that the index exceeds the size of the view
- Parameters
i: index at which to get the data
-
value_type
at(size_t i) const¶ get value at index i
Return the value of the element at linear index i within the view. Unlike the [] operators this member function will throw an exception if the index exceeds the size of the view.
- Return
- reference to the element at index i
- Exceptions
index_error: in case that the index exceeds the size of the view
- Parameters
i: index at which to get the data
-
void
insert(size_t i, const value_type &v)¶ insert value at i
Insert a new value at the linear index i of the view.
- Exceptions
index_error: if i exceeds total size
- Parameters
i: linear indexv: new value to insert
-
value_type &
front()¶ return reference to the first element
-
value_type
front() const¶ return value of first element
-
value_type &
back()¶ return reference ot the last vlaue
-
value_type
back() const¶ return value of last element
-
size_t
size() const¶ get size
Return the total number of elements referenced by this view.
- Return
- total number of elements
-
size_t
rank() const¶ get rank of the view
Returns the number of dimensions of the array.
- Return
- number of dimensions
-
iterator
begin()¶ iterator to first element
Return an interator to the first element of the array view.
- Return
- iterator to the first element
-
iterator
end()¶ iterator to last element
Return an iterator to the last element of the array view.
- Return
- iterator to last element
-
const_iterator
begin() const¶ const iterator to first element
Return an const interator to the first element of the array view.
- Return
- iterator to the first element
-
const_iterator
end() const¶ const iterator to last element
Return an const iterator to the last+1 element of the array view. The iterator is thus invalid.
- Return
- iterator to last element
-
array_type &
operator+=(value_type s)¶ unary addition of a scalar
!array_type a = ...; array_type::value_type s = ...; auto view = a(0,slice(0,100),slice(3,23)); view += s;
- Return
- view reference
- Parameters
s: the scalar value to add
-
template <typename RTYPE>
array_type &operator+=(const RTYPE &v)¶ unary addition of an array
!array_type1 a = ...; array_tyep2 b = ...; auto view = a(1,slice(0,100),slice(3,23)); view += b;
- Return
- reference to the original view
- Template Parameters
RTYPE: type of the array to add
- Parameters
v: reference to the array to add
-
array_type &
operator-=(value_type s)¶ unary subtraction of a scalar
!array_type a = ...; array_type::value_type s = ...; auto view = a(0,slice(0,100),slice(3,23)); view -= s;
- Return
- view reference
- Parameters
s: the scalar value to subtract
-
template <typename RTYPE>
array_type &operator-=(const RTYPE &v)¶ unary subtraction of an array
!array_type1 a = ...; array_tyep2 b = ...; auto view = a(0,slice(0,100),slice(2,23)); view -= b;
- Return
- reference to the original view
- Template Parameters
RTYPE: type of the array to subtract
- Parameters
v: reference to the array to subtract
-
array_type &
operator*=(value_type s)¶ unary multiplication of a scalar
!array_type a = ...; array_type::value_type s = ...; auto view = a(slice(0,100),10,slice(2,23)); view *= s;
- Return
- view reference
- Parameters
s: the scalar value to multiply with
-
template <typename RTYPE>
array_type &operator*=(const RTYPE &v)¶ unary multiplication of an array
!array_type1 a = ...; array_tyep2 b = ...; auto view = a(slice(0,100),100,slice(2,102)); view *= b;
- Return
- reference to the original view
- Template Parameters
RTYPE: type of the array to multiply
- Parameters
v: reference to the array to multiply
-
array_type &
operator/=(value_type s)¶ unary division of a scalar
!array_type a = ...; array_type::value_type s = ...; auto view = a(slice(0,100),slice(2,3),slice(4,10)); view /= s;
- Return
- array reference
- Parameters
s: the scalar value to divide by
-
template <typename RTYPE>
array_type &operator/=(const RTYPE &v)¶ unary division of an array
!array_type1 a = ...; array_tyep2 b = ...; auto view = a(slice(0,100),10,10); view /= b;
- Return
- reference to the original view
- Template Parameters
RTYPE: type of the array to divide by
- Parameters
v: reference to the array to divide by
-
const map_type &
map() const¶ return reference to index map
-
bool
is_contiguous() const¶ check if contiguous
Returns true if the view is contiguous. Otherweise false.
- Return
- true if contiguous selection, false otherwise
Operators¶
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator==” with arguments (const array_view< ATYPE > &, const array_view< ATYPE > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT bool pni::core::operator==(const complex128&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator==(const complex128&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator==(const complex32&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator==(const complex32&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator==(const complex64&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator==(const complex64&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator==(const none&, const none&)
- PNICORE_EXPORT bool pni::core::operator==(const slice&, const slice&)
- template <typename ATYPE>
bool pni::core::operator==(const array_view<ATYPE>&, const array_view<ATYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
bool pni::core::operator==(const mdarray<STORAGE, IMAP, IPA>&, const mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
bool pni::core::operator==(const scalar<T>&, const scalar<T>&)
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator!=” with arguments (const array_view< ATYPE > &, const array_view< ATYPE > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT bool pni::core::operator!=(const complex128&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex128&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex32&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex32&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex64&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex64&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator!=(const none&, const none&)
- PNICORE_EXPORT bool pni::core::operator!=(const slice&, const slice&)
- template <typename ATYPE>
bool pni::core::operator!=(const array_view<ATYPE>&, const array_view<ATYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
bool pni::core::operator!=(const mdarray<STORAGE, IMAP, IPA>&, const mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
bool pni::core::operator!=(const scalar<T>&, const scalar<T>&)
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator>>” with arguments (std::istream &, array_view< ATYPE > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT std::istream &pni::core::operator>>(std::istream&, bool_t&)
- PNICORE_EXPORT std::istream &pni::core::operator>>(std::istream&, none&)
- template <typename ATYPE>
std::istream &pni::core::operator>>(std::istream&, array_view<ATYPE>&)
- template <typename NTYPE>
std::istream &pni::core::operator>>(std::istream&, binary_t<NTYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
std::istream &pni::core::operator>>(std::istream&, mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
std::istream &pni::core::operator>>(std::istream&, scalar<T>&)
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator<<” with arguments (std::ostream &, const array_view< ATYPE > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const bool_t&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const exception_record&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const none&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const slice&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const type_id_t&)
- std::ostream &pni::core::operator<<(std::ostream&, const array_selection&)
- std::ostream &pni::core::operator<<(std::ostream&, const benchmark_result&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_args&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_argument_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_help_request&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_option_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const configuration&)
- std::ostream &pni::core::operator<<(std::ostream&, const exception&)
- std::ostream &pni::core::operator<<(std::ostream&, const file_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const index_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const iterator_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const key_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const memory_allocation_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const memory_not_allocated_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const not_implemented_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const range_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const shape_mismatch_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const size_mismatch_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const type_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const value_error&)
- template <typename ATYPE>
std::ostream &pni::core::operator<<(std::ostream&, const array_view<ATYPE>&)
- template <typename NTYPE>
std::ostream &pni::core::operator<<(std::ostream&, const binary_t<NTYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
std::ostream &pni::core::operator<<(std::ostream&, const mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
std::ostream &pni::core::operator<<(std::ostream&, const scalar<T>&)
scalar¶
-
template <typename T>
classscalar¶ Scalar template for scalar values.
This template is used in expression tempaltes. Its purpose is to give scalar values an array like interface.
- Template Parameters
T: scalar type of the data stored.
Public Types
-
typedef T
value_type¶ native data type of the scalar
-
typedef std::array<T, 1>
storage_type¶ storage type
-
typedef scalar_iterator<array_type>
iterator¶ iterator
-
typedef scalar_iterator<const array_type>
const_iterator¶ const iterator
-
typedef array_view<array_type>
view_type¶ view type
Public Functions
-
scalar()¶ default constructor
-
scalar(const array_type &s)¶ copy constructor
-
scalar(const value_type &r)¶ constructor from a scalar value
-
~scalar()¶ destructor
-
array_type &
operator=(const value_type &v)¶ assignment from T value
Assigns a value of type T to the scalar.
- Return
- reference to array_type
- Parameters
v: value to assign
-
array_type &
operator=(const array_type &v)¶ assignment from Scalar<T>
This is the most trivial case. An object of type Scalar<T> is assigned to an other object of type Scalar<T>.
- Return
- reference to array_type
- Parameters
v: value of scalar<T> to assign
-
operator T() const¶ conversion operator
Allows conversion from an instance of scalar<T> to a variable of type T.
- Return
- value of type T
-
T
operator[](size_t) const¶ get data
Return the single data value independent of what value of i is given.
- Return
- value of the scalar
- Parameters
i: linear index of the value
-
T &
operator[](size_t)¶ get reference to data
Return a reference to the data stored in the scalar. No matter what value of i is passed to this operator - it will always return the same reference.
- Return
- reference to the scalar data
- Parameters
i: index
-
T
at(size_t) const¶ get data value
Return the value of the data stored in the instance no matter of the value of the index.
- Return
- data value
- Parameters
i: index
-
T &
at(size_t)¶ get data reference
Return a reference to the data stored in the scalar no matter what index is passed to the method.
- Return
- reference to data
- Parameters
i: index
-
void
insert(size_t, const T &v)¶ set data value
Method to set a data value. The index does not matter.
- Parameters
i: indexv: value
-
const storage_type &
storage() const¶ get reference to the storage object
Return a const reference to the static buffer that holds the scalar data.
- Return
- reference to buffer object
-
template <typename ... ITYPES>
T &operator()(ITYPES...)¶ get reference to the data
Returns the reference to the data value no matter how many or what indices are passed.
- Return
- reference to data
- Template Parameters
ITYPES: index types
- Parameters
indices: multidimensional index
-
template <typename ... ITYPES>
Toperator()(ITYPES...) const¶ get value of data
Return the value of the scalar. The number of indices or their type do not matter.
- Return
- data value
- Template Parameters
ITYPES: index types
- Parameters
indices: multidimensional index
-
template <template< typename ... > class CTYPE, typename ... OTS>
T &operator()(const CTYPE<OTS...>&)¶ get reference to data
Return a reference to the data. The multidimensional index is passed by a container. The number of indices or their value are ignored.
- Return
- reference to the data
- Template Parameters
CTYPE: container templateOTS: template arguments for the container template
-
template <template< typename ... > class CTYPE, typename ... OTS>
Toperator()(const CTYPE<OTS...>&) const¶ get data value
Return the data value. The multidimensional index is passed by a container. The number of indices or their value are ignored.
- Return
- data value
- Template Parameters
CTYPE: container templateOTS: template arguments of the container template
-
size_t
size() const¶ get size
For a scalar object this method always returns 1. This is due to the fact that one needs to allocate only one block of memory of sizeof(T) bytes to hold the scalar data.
- Return
- 1
-
size_t
rank() const¶ get rank
Return the number of dimensions of the scalar. This is always 0.
- Return
- 0
-
template <typename CTYPE>
CTYPEshape() const¶ get shape
Returns the shape of the scalar - this is a container with a single value 1.
- Return
- container with 1
-
const_iterator
begin() const¶ get const iterator to first element
-
const_iterator
end() const¶ get const iterator to last+1 element
Operators¶
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator==” with arguments (const scalar< T > &, const scalar< T > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT bool pni::core::operator==(const complex128&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator==(const complex128&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator==(const complex32&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator==(const complex32&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator==(const complex64&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator==(const complex64&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator==(const none&, const none&)
- PNICORE_EXPORT bool pni::core::operator==(const slice&, const slice&)
- template <typename ATYPE>
bool pni::core::operator==(const array_view<ATYPE>&, const array_view<ATYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
bool pni::core::operator==(const mdarray<STORAGE, IMAP, IPA>&, const mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
bool pni::core::operator==(const scalar<T>&, const scalar<T>&)
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator!=” with arguments (const scalar< T > &, const scalar< T > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT bool pni::core::operator!=(const complex128&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex128&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex32&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex32&, const complex64&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex64&, const complex128&)
- PNICORE_EXPORT bool pni::core::operator!=(const complex64&, const complex32&)
- PNICORE_EXPORT bool pni::core::operator!=(const none&, const none&)
- PNICORE_EXPORT bool pni::core::operator!=(const slice&, const slice&)
- template <typename ATYPE>
bool pni::core::operator!=(const array_view<ATYPE>&, const array_view<ATYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
bool pni::core::operator!=(const mdarray<STORAGE, IMAP, IPA>&, const mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
bool pni::core::operator!=(const scalar<T>&, const scalar<T>&)
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator<<” with arguments (std::ostream &, const scalar< T > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const bool_t&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const exception_record&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const none&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const slice&)
- PNICORE_EXPORT std::ostream &pni::core::operator<<(std::ostream&, const type_id_t&)
- std::ostream &pni::core::operator<<(std::ostream&, const array_selection&)
- std::ostream &pni::core::operator<<(std::ostream&, const benchmark_result&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_args&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_argument_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_help_request&)
- std::ostream &pni::core::operator<<(std::ostream&, const cli_option_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const configuration&)
- std::ostream &pni::core::operator<<(std::ostream&, const exception&)
- std::ostream &pni::core::operator<<(std::ostream&, const file_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const index_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const iterator_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const key_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const memory_allocation_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const memory_not_allocated_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const not_implemented_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const range_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const shape_mismatch_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const size_mismatch_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const type_error&)
- std::ostream &pni::core::operator<<(std::ostream&, const value_error&)
- template <typename ATYPE>
std::ostream &pni::core::operator<<(std::ostream&, const array_view<ATYPE>&)
- template <typename NTYPE>
std::ostream &pni::core::operator<<(std::ostream&, const binary_t<NTYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
std::ostream &pni::core::operator<<(std::ostream&, const mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
std::ostream &pni::core::operator<<(std::ostream&, const scalar<T>&)
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::operator>>” with arguments (std::istream &, scalar< T > &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT std::istream &pni::core::operator>>(std::istream&, bool_t&)
- PNICORE_EXPORT std::istream &pni::core::operator>>(std::istream&, none&)
- template <typename ATYPE>
std::istream &pni::core::operator>>(std::istream&, array_view<ATYPE>&)
- template <typename NTYPE>
std::istream &pni::core::operator>>(std::istream&, binary_t<NTYPE>&)
- template <typename STORAGE, typename IMAP, typename IPA>
std::istream &pni::core::operator>>(std::istream&, mdarray<STORAGE, IMAP, IPA>&)
- template <typename T>
std::istream &pni::core::operator>>(std::istream&, scalar<T>&)
slice¶
-
class
slice¶ index slice
This types represents an index slice for an array. A slice can be used to identify an index range along a single dimensions. slice objects are of particular importance for creating array_view from mdarray instancers.
A slice includes all indices between the the first and last index of the slice where the last index is not included. A stride can be passed during construction which determines the number of steps between each subsequent element. If the stride is not 1 the last index will be adopted so that the
Public Functions
-
slice()¶ default constructor
-
slice(size_t first, size_t last, size_t stride = 1)¶ standard constructor
This is the default constructor for a Slice object.
- Exceptions
range_error: if the first index exceeds the last
- Parameters
first: first indexlast: indexstride: steps between subsequent elements
-
slice(const std::initializer_list<size_t> &l)¶ construction from a initializer list
This can be used for implicit conversion which is sometimes quite useful for the creation fo array views.
! If the initializer list has only two elements they are treated as first and last element of the slice and the stride is set to 1. In the case of a three element initializer list the last element is considered as the stride of the slice.mdarray<...> a({10,100}); //default construction of a view auto v1 = a(slice(1,4),slice(50,100)); //one can also use initializer lists auto v2 = a({1,4},{50,100});
- Exceptions
range_error: if the first element is larger than the last
- Parameters
l: initializer list
-
slice(size_t index)¶ construction from a single index
Constructor uses a single index. This constructor is equivalent to use slice(index,index+1,1).
- Parameters
index: single index from which to create the slice
-
~slice()¶ destructor
-
size_t
first() const¶ return the first element
- Return
- first element of slice
-
size_t
last() const¶ return last element
- Return
- last element of slice
-
size_t
stride() const¶ return stride
- Return
- stride of the slice
-
Functions¶
Warning
doxygenfunction: Unable to resolve multiple matches for function “pni::core::size” with arguments (const slice &) in doxygen xml output for project “pnicore” from directory: /home/jkotan/sources/libpnicore-build/doc/api_doc/xml. Potential matches:
- PNICORE_EXPORT size_t pni::core::size(const slice&)
- size_t pni::core::size(const array_selection&)