|
dune-common 2.12-git
|
An owning multi-dimensional array analog of mdspan. More...
#include <dune/common/std/mdarray.hh>
Public Types | |
| using | element_type = Element |
| using | extents_type = Extents |
| using | layout_type = LayoutPolicy |
| using | container_type = Container |
| using | value_type = element_type |
| using | mapping_type = typename layout_type::template mapping< extents_type > |
| using | index_type = typename extents_type::index_type |
| using | size_type = typename extents_type::size_type |
| using | rank_type = typename extents_type::rank_type |
| using | mdspan_type = mdspan< element_type, extents_type, layout_type > |
| using | const_mdspan_type = mdspan< const element_type, extents_type, layout_type > |
| using | pointer = decltype(std::to_address(std::declval< container_type >().begin())) |
| using | reference = typename container_type::reference |
| using | const_pointer = decltype(std::to_address(std::declval< container_type >().cbegin())) |
| using | const_reference = typename container_type::const_reference |
Public Member Functions | |
| constexpr const mapping_type & | mapping () const noexcept |
| Index mapping of a layout policy. | |
| constexpr const container_type & | container () const noexcept |
| The underlying storage container. | |
| constexpr container_type && | extract_container () &&noexcept |
| Move the container out of the mdarray. | |
| constexpr bool | is_unique () const noexcept |
| constexpr bool | is_exhaustive () const noexcept |
| constexpr bool | is_strided () const noexcept |
Static Public Member Functions | |
| static constexpr bool | is_always_unique () noexcept |
| static constexpr bool | is_always_exhaustive () noexcept |
| static constexpr bool | is_always_strided () noexcept |
Friends | |
| template<class , class , class , class > | |
| class | mdarray |
| constexpr void | swap (mdarray &x, mdarray &y) noexcept |
Related Symbols | |
(Note that these are not member symbols.) | |
| constexpr const extents_type & | extents () const noexcept |
| Number of elements in all dimensions of the array,. | |
Comparison operators | |
| constexpr bool | operator== (const mdarray &lhs, const mdarray &rhs) noexcept |
Conversion into mdspan | |
| container_type | container_ |
| DUNE_NO_UNIQUE_ADDRESS 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. | |
mdarray constructors | |
| 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< value_type &, typename Accessor::reference >, 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. | |
Multi index access | |
| 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,...}]. | |
Size information | |
| constexpr index_type | extent (rank_type r) const noexcept |
| Number of elements in the r'th dimension of the tensor. | |
| constexpr size_type | size () const noexcept |
| Size of the multi-dimensional index space. | |
| constexpr std::size_t | container_size () const |
| Size of the underlying container. | |
| constexpr bool | empty () const noexcept |
| Check whether the index space is empty. | |
| constexpr index_type | stride (rank_type r) const |
| The stride along the specified dimension. | |
| static constexpr rank_type | rank () noexcept |
| Number of dimensions of the array. | |
| static constexpr rank_type | rank_dynamic () noexcept |
| Number of dimension with dynamic size. | |
| static constexpr std::size_t | static_extent (rank_type r) noexcept |
| Number of elements in the r'th dimension of the tensor. | |
Direct access to the data | |
| constexpr pointer | container_data () noexcept |
| Direct access to the underlying data in the container. | |
| constexpr const_pointer | container_data () const noexcept |
| Direct access to the underlying const data in the container. | |
Detailed Description
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:
- Note
- The interface of
Std::mdarrayprovides theoperator[]with multiple indices overload only if available in c++23. For older c++ versions theoperator()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.
Member Typedef Documentation
◆ const_mdspan_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::const_mdspan_type = mdspan<const element_type,extents_type,layout_type> |
◆ const_pointer
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::const_pointer = decltype(std::to_address(std::declval<container_type>().cbegin())) |
◆ const_reference
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::const_reference = typename container_type::const_reference |
◆ container_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container_type = Container |
◆ element_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::element_type = Element |
◆ extents_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::extents_type = Extents |
◆ index_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::index_type = typename extents_type::index_type |
◆ layout_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::layout_type = LayoutPolicy |
◆ mapping_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mapping_type = typename layout_type::template mapping<extents_type> |
◆ mdspan_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdspan_type = mdspan<element_type,extents_type,layout_type> |
◆ pointer
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::pointer = decltype(std::to_address(std::declval<container_type>().begin())) |
◆ rank_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::rank_type = typename extents_type::rank_type |
◆ reference
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::reference = typename container_type::reference |
◆ size_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::size_type = typename extents_type::size_type |
◆ value_type
| using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::value_type = element_type |
Constructor & Destructor Documentation
◆ mdarray() [1/22]
|
inlineconstexpr |
A default constructor; needed only if the constructor for dynamic extents does not apply.
◆ mdarray() [2/22]
|
inlineexplicitconstexpr |
Construct from the dynamic extents.
◆ mdarray() [3/22]
|
inlineexplicitconstexpr |
Construct from the extents of the array.
◆ mdarray() [4/22]
|
inlineexplicitconstexpr |
Construct from the layout mapping of the array.
◆ mdarray() [5/22]
|
inlineconstexpr |
Construct from extents and initial value.
◆ mdarray() [6/22]
|
inlineconstexpr |
Construct from layout mapping and initial value.
◆ mdarray() [7/22]
|
inlineconstexpr |
Construct from extents and the storage container.
◆ mdarray() [8/22]
|
inlineconstexpr |
Construct from extents and the storage container.
◆ mdarray() [9/22]
|
inlineconstexpr |
Construct from layout mapping and the storage container.
◆ mdarray() [10/22]
|
inlineconstexpr |
Construct from layout mapping and the storage container.
◆ mdarray() [11/22]
|
inlineconstexpr |
Converting constructor from other mdarray.
◆ mdarray() [12/22]
|
inlineconstexpr |
Converting constructor from mdspan.
◆ mdarray() [13/22]
|
inlineconstexpr |
Construct from the extents of the array and allocator.
◆ mdarray() [14/22]
|
inlineconstexpr |
Construct from the layout mapping of the array and allocator.
◆ mdarray() [15/22]
|
inlineconstexpr |
Construct from extents, initial value and allocator.
◆ mdarray() [16/22]
|
inlineconstexpr |
Construct from layout mapping, initial value and allocator.
◆ mdarray() [17/22]
|
inlineconstexpr |
Construct from extents, container and allocator.
◆ mdarray() [18/22]
|
inlineconstexpr |
Construct from extents, container and allocator.
◆ mdarray() [19/22]
|
inlineconstexpr |
Construct from layout mapping, container and allocator.
◆ mdarray() [20/22]
|
inlineconstexpr |
Construct from layout mapping, container and allocator.
◆ mdarray() [21/22]
|
inlineconstexprnoexcept |
Converting constructor with alternative allocator.
◆ mdarray() [22/22]
|
inlineconstexpr |
Converting constructor from mdspan.
Member Function Documentation
◆ container()
|
inlineconstexprnoexcept |
The underlying storage container.
◆ container_data() [1/2]
|
inlineconstexprnoexcept |
Direct access to the underlying const data in the container.
◆ container_data() [2/2]
|
inlineconstexprnoexcept |
Direct access to the underlying data in the container.
◆ container_size()
|
inlineconstexpr |
Size of the underlying container.
◆ empty()
|
inlineconstexprnoexcept |
Check whether the index space is empty.
◆ extent()
|
inlineconstexprnoexcept |
Number of elements in the r'th dimension of the tensor.
◆ extract_container()
|
inlineconstexprnoexcept |
Move the container out of the mdarray.
Note that after moving out the container the mdarray remains in a valid but an unspecified state. One can destruct it or move-assign to it (i.e. restore the container in some way).
◆ is_always_exhaustive()
|
inlinestaticconstexprnoexcept |
◆ is_always_strided()
|
inlinestaticconstexprnoexcept |
◆ is_always_unique()
|
inlinestaticconstexprnoexcept |
◆ is_exhaustive()
|
inlineconstexprnoexcept |
◆ is_strided()
|
inlineconstexprnoexcept |
◆ is_unique()
|
inlineconstexprnoexcept |
◆ mapping()
|
inlineconstexprnoexcept |
Index mapping of a layout policy.
◆ operator mdspan< V, E, L, A >() [1/2]
|
inlineconstexpr |
Conversion operator to mdspan.
◆ operator mdspan< V, E, L, A >() [2/2]
|
inlineconstexpr |
Conversion operator to mdspan.
◆ operator()() [1/2]
|
inlineconstexpr |
Access element at position (i0,i1,...)
- Note
- The
operator()is not in the std proposal, but is provided for using mdspan without c++23. For compatibility reasons it should only be used if the macro DUNE_HAVE_CXX_STD_MDARRAY is explicitly set to 0.
◆ operator()() [2/2]
|
inlineconstexpr |
Access element at position (i0,i1,...)
- Note
- The
operator()is not in the std proposal, but is provided for using mdspan without c++23.
◆ operator[]() [1/6]
|
inlineconstexpr |
Access element at position [{i0,i1,...}].
◆ operator[]() [2/6]
|
inlineconstexpr |
Access element at position [{i0,i1,...}].
◆ operator[]() [3/6]
|
inlineconstexpr |
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.
◆ operator[]() [4/6]
|
inlineconstexpr |
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.
◆ operator[]() [5/6]
|
inlineconstexpr |
Access element at position [{i0,i1,...}].
◆ operator[]() [6/6]
|
inlineconstexpr |
Access element at position [{i0,i1,...}].
◆ rank()
|
inlinestaticconstexprnoexcept |
Number of dimensions of the array.
◆ rank_dynamic()
|
inlinestaticconstexprnoexcept |
Number of dimension with dynamic size.
◆ size()
|
inlineconstexprnoexcept |
Size of the multi-dimensional index space.
◆ static_extent()
|
inlinestaticconstexprnoexcept |
Number of elements in the r'th dimension of the tensor.
◆ stride()
|
inlineconstexpr |
The stride along the specified dimension.
◆ to_mdspan() [1/2]
|
inlineconstexpr |
Conversion function to mdspan.
◆ to_mdspan() [2/2]
|
inlineconstexpr |
Conversion function to mdspan.
Friends And Related Symbol Documentation
◆ extents()
|
related |
Number of elements in all dimensions of the array,.
◆ mdarray
|
friend |
◆ operator==
|
friend |
◆ swap
|
friend |
Member Data Documentation
◆ container_
|
protected |
◆ mapping_
|
protected |
The documentation for this class was generated from the following file:
Legal Statements / Impressum | Hosted by TU Dresden & Uni Heidelberg | Generated by
1.9.8