|
| container_type | container_ |
| mapping_type | mapping_ |
| template<class V, class E, class L, class A, std::enable_if_t< std::is_assignable_v< mdspan< V, E, L, A >, mdspan_type >, int > = 0> |
| constexpr | operator mdspan< V, E, L, A > () |
| | Conversion operator to mdspan.
|
| template<class V, class E, class L, class A, std::enable_if_t< std::is_assignable_v< mdspan< V, E, L, A >, const_mdspan_type >, int > = 0> |
| constexpr | operator mdspan< V, E, L, A > () const |
| | Conversion operator to mdspan.
|
| template<class AccessorPolicy = Std::default_accessor<element_type>, std::enable_if_t< std::is_assignable_v< mdspan_type, mdspan< element_type, extents_type, layout_type, AccessorPolicy > >, int > = 0> |
| constexpr mdspan< element_type, extents_type, layout_type, AccessorPolicy > | to_mdspan (const AccessorPolicy &a=AccessorPolicy{}) |
| | Conversion function to mdspan.
|
| template<class AccessorPolicy = Std::default_accessor<const element_type>, std::enable_if_t< std::is_assignable_v< const_mdspan_type, mdspan< const element_type, extents_type, layout_type, AccessorPolicy > >, int > = 0> |
| constexpr mdspan< const element_type, extents_type, layout_type, AccessorPolicy > | to_mdspan (const AccessorPolicy &a=AccessorPolicy{}) const |
| | Conversion function to mdspan.
|
|
| template<class E = extents_type, class C = container_type, class M = mapping_type, std::enable_if_t<(E::rank_dynamic() !=0), int > = 0, std::enable_if_t< std::is_default_constructible_v< C >, int > = 0, std::enable_if_t< std::is_default_constructible_v< M >, int > = 0> |
| constexpr | mdarray () |
| | A default constructor; needed only if the constructor for dynamic extents does not apply.
|
| template<class... IndexTypes, std::enable_if_t<(... &&std::is_convertible_v< IndexTypes, index_type >), int > = 0, std::enable_if_t< std::is_constructible_v< extents_type, IndexTypes... >, int > = 0, std::enable_if_t<(... &&std::is_nothrow_constructible_v< index_type, IndexTypes >), int > = 0> |
| constexpr | mdarray (IndexTypes... exts) |
| | Construct from the dynamic extents.
|
| constexpr | mdarray (const extents_type &e) |
| | Construct from the extents of the array.
|
| template<class C = container_type, decltype(construct_container< C >(std::declval< std::size_t >()), bool{}) = true> |
| constexpr | mdarray (const mapping_type &m) |
| | Construct from the layout mapping of the array.
|
| constexpr | mdarray (const extents_type &e, const value_type &v) |
| | Construct from extents and initial value.
|
| template<class C = container_type, decltype(construct_container< C >(std::declval< std::size_t >(), std::declval< const value_type & >()), bool{}) = true> |
| constexpr | mdarray (const mapping_type &m, const value_type &v) |
| | Construct from layout mapping and initial value.
|
| template<class E = extents_type, std::enable_if_t< std::is_constructible_v< mapping_type, const E & >, int > = 0> |
| constexpr | mdarray (const E &e, const container_type &c) |
| | Construct from extents and the storage container.
|
| template<class E = extents_type, std::enable_if_t< std::is_constructible_v< mapping_type, const E & >, int > = 0> |
| constexpr | mdarray (const E &e, container_type &&c) |
| | Construct from extents and the storage container.
|
| constexpr | mdarray (const mapping_type &m, const container_type &c) |
| | Construct from layout mapping and the storage container.
|
| constexpr | mdarray (const mapping_type &m, container_type &&c) |
| | Construct from layout mapping and the storage container.
|
| template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherContainer, std::enable_if_t< std::is_constructible_v< Container, const OtherContainer & >, int > = 0, std::enable_if_t< std::is_constructible_v< extents_type, OtherExtents >, int > = 0, std::enable_if_t< std::is_constructible_v< mapping_type, const typename OtherLayoutPolicy::template mapping< OtherExtents > & >, int > = 0> |
| constexpr | mdarray (const mdarray< OtherElementType, OtherExtents, OtherLayoutPolicy, OtherContainer > &other) |
| | Converting constructor from other mdarray.
|
| template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class Accessor, std::enable_if_t< std::is_constructible_v< value_type, typename Accessor::reference >, int > = 0, std::enable_if_t< std::is_assignable_v< typename Accessor::reference, value_type >, int > = 0, std::enable_if_t< std::is_constructible_v< mapping_type, const typename OtherLayoutPolicy::template mapping< OtherExtents > & >, int > = 0, decltype(construct_container< container_type >(std::declval< std::size_t >()), bool{}) = true> |
| constexpr | mdarray (const mdspan< OtherElementType, OtherExtents, OtherLayoutPolicy, Accessor > &other) |
| | Converting constructor from mdspan.
|
| template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, std::size_t, Alloc >, int > = 0> |
| constexpr | mdarray (const extents_type &e, const Alloc &a) |
| | Construct from the extents of the array and allocator.
|
| template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, std::size_t, Alloc >, int > = 0> |
| constexpr | mdarray (const mapping_type &m, const Alloc &a) |
| | Construct from the layout mapping of the array and allocator.
|
| template<class Alloc> |
| constexpr | mdarray (const extents_type &e, const value_type &v, const Alloc &a) |
| | Construct from extents, initial value and allocator.
|
| template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, std::size_t, value_type, Alloc >, int > = 0> |
| constexpr | mdarray (const mapping_type &m, const value_type &v, const Alloc &a) |
| | Construct from layout mapping, initial value and allocator.
|
| template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, container_type, Alloc >, int > = 0> |
| constexpr | mdarray (const extents_type &e, const container_type &c, const Alloc &a) |
| | Construct from extents, container and allocator.
|
| template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, container_type, Alloc >, int > = 0> |
| constexpr | mdarray (const extents_type &e, container_type &&c, const Alloc &a) |
| | Construct from extents, container and allocator.
|
| template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, container_type, Alloc >, int > = 0> |
| constexpr | mdarray (const mapping_type &m, const container_type &c, const Alloc &a) |
| | Construct from layout mapping, container and allocator.
|
| template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, container_type, Alloc >, int > = 0> |
| constexpr | mdarray (const mapping_type &m, container_type &&c, const Alloc &a) |
| | Construct from layout mapping, container and allocator.
|
| template<class V, class E, class L, class C, class Alloc, std::enable_if_t< std::is_constructible_v< container_type, C, Alloc >, int > = 0> |
| constexpr | mdarray (const mdarray< V, E, L, C > &other, const Alloc &a) noexcept |
| | Converting constructor with alternative allocator.
|
| template<class V, class E, class L, class A, class Alloc, class C = container_type, class Al = typename C::allocator_type, std::enable_if_t< std::is_constructible_v< C, std::size_t, Alloc >, int > = 0> |
| constexpr | mdarray (const mdspan< V, E, L, A > &other, const Alloc &a) |
| | Converting constructor from mdspan.
|
|
| template<class... Indices, std::enable_if_t<(sizeof...(Indices)==extents_type::rank()), int > = 0, std::enable_if_t<(... &&std::is_convertible_v< Indices, index_type >), int > = 0> |
| constexpr reference | operator() (Indices... indices) |
| | Access element at position (i0,i1,...).
|
| template<class... Indices, std::enable_if_t<(sizeof...(Indices)==extents_type::rank()), int > = 0, std::enable_if_t<(... &&std::is_convertible_v< Indices, index_type >), int > = 0> |
| constexpr const_reference | operator() (Indices... indices) const |
| | Access element at position (i0,i1,...).
|
| template<class Index, class E = extents_type, std::enable_if_t< std::is_convertible_v< Index, index_type >, int > = 0, std::enable_if_t<(E::rank()==1), int > = 0> |
| constexpr reference | operator[] (Index index) |
| | Access specified element at position [i0] For a rank one mdarray, the operator[i] is added to support bracket access before __cpp_multidimensional_subscript is supported.
|
| template<class Index, class E = extents_type, std::enable_if_t< std::is_convertible_v< Index, index_type >, int > = 0, std::enable_if_t<(E::rank()==1), int > = 0> |
| constexpr const_reference | operator[] (Index index) const |
| | Access specified element at position [i0] For a rank one mdarray, the operator[i] is added to support bracket access before __cpp_multidimensional_subscript is supported.
|
| template<class Index, std::enable_if_t< std::is_convertible_v< const Index &, index_type >, int > = 0> |
| constexpr reference | operator[] (Std::span< Index, extents_type::rank()> indices) |
| | Access element at position [{i0,i1,...}].
|
| template<class Index, std::enable_if_t< std::is_convertible_v< const Index &, index_type >, int > = 0> |
| constexpr const_reference | operator[] (Std::span< Index, extents_type::rank()> indices) const |
| | Access element at position [{i0,i1,...}].
|
| template<class Index, std::enable_if_t< std::is_convertible_v< const Index &, index_type >, int > = 0> |
| constexpr reference | operator[] (const std::array< Index, extents_type::rank()> &indices) |
| | Access element at position [{i0,i1,...}].
|
| template<class Index, std::enable_if_t< std::is_convertible_v< const Index &, index_type >, int > = 0> |
| constexpr const_reference | operator[] (const std::array< Index, extents_type::rank()> &indices) const |
| | Access element at position [{i0,i1,...}].
|
template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
class Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >
An owning multi-dimensional array analog of mdspan.
The implementation is inspired by the mdarray c++ standard proposals P1684R5.
Example:
template <class T, int m, int n>
for (std::size_t i = 0; i != m1.
extent(0); i++)
for (std::size_t j = 0; j != m1.
extent(1); j++)
m1(i, j) = i + j;
A dense n x m matrix.
Definition fmatrix.hh:117
Multidimensional index space with dynamic and static extents.
Definition extents.hh:54
A layout where the rightmost extent has stride 1, and strides increase right-to-left as the product o...
Definition fwd_layouts.hh:30
An owning multi-dimensional array analog of mdspan.
Definition mdarray.hh:69
constexpr index_type extent(rank_type r) const noexcept
Number of elements in the r'th dimension of the tensor.
Definition mdarray.hh:498
- Note
- The interface of Std::mdarray provides the operator[] with multiple indices overload only if available in c++23. For older c++ versions the operator() overload is implemented.
- Template Parameters
-
| Element | The element type; a complete object type that is neither an abstract class type nor an array type. |
| Extents | Specifies number of dimensions, their sizes, and which are known at compile time. Must be a specialization of Std::extents. |
| LayoutPolicy | Specifies how to convert multi-dimensional index to underlying flat index. |
| Container | A container type accessible by a single index provided by the layout mapping. |