DUNE-FEM (2.10)
A multi-dimensional non-owning array view. More...
#include <dune/common/std/mdspan.hh>
Public Member Functions | |
constexpr const mapping_type & | mapping () const noexcept |
Index mapping of a layout policy. | |
constexpr const accessor_type & | accessor () const noexcept |
The accessor policy object. | |
constexpr const data_handle_type & | data_handle () const noexcept |
The pointer to the underlying flat sequence. | |
constexpr bool | is_unique () const |
Return true only if for every i and j where (i != j || ...) => mapping(i...) != mapping(j...). | |
constexpr bool | is_exhaustive () const |
Return true only if for all k in the range [0, mapping.required_span_size() ) there exists an i such that mapping(i...) equals k. | |
constexpr bool | is_strided () const |
Return true only if for every rank index r of extents there exists an integer sr such that, for all i where (i+dr) is a multidimensional index in extents, mapping((i+dr)...) - mapping(i...) equals sr. *. More... | |
constexpr index_type | stride (rank_type r) const |
The stride along the specified dimension. | |
Static Public Member Functions | |
static constexpr bool | is_always_unique () |
Return true only if for every i and j where (i != j || ...) => mapping(i...) != mapping(j...). More... | |
static constexpr bool | is_always_exhaustive () |
Return true only if for all k in the range [0, mapping.required_span_size() ) there exists an i such that mapping(i...) equals k. More... | |
static constexpr bool | is_always_strided () |
Return true only if for every rank index r of extents there exists an integer sr such that, for all i where (i+dr) is a multidimensional index in extents, mapping((i+dr)...) - mapping(i...) equals sr. *. More... | |
Related Functions | |
(Note that these are not member functions.) | |
constexpr const extents_type & | extents () const noexcept |
Number of elements in all dimensions of the tensor,. | |
mdspan constructors [mdspan.mdspan.cons] | |
template<class E = extents_type, class D = data_handle_type, class M = mapping_type, class A = accessor_type, std::enable_if_t<(E::rank_dynamic() > 0), int > = 0, std::enable_if_t< std::is_default_constructible_v< D >, int > = 0, std::enable_if_t< std::is_default_constructible_v< M >, int > = 0, std::enable_if_t< std::is_default_constructible_v< A >, int > = 0> | |
constexpr | mdspan () |
Default constructor value-initializes all members. | |
template<class... IndexTypes, class E = extents_type, class M = mapping_type, class A = accessor_type, std::enable_if_t<(sizeof...(IndexTypes)==E::rank()||sizeof...(IndexTypes)==E::rank_dynamic()), int > = 0, std::enable_if_t<(... &&std::is_convertible_v< IndexTypes, index_type >), int > = 0, std::enable_if_t<(... &&std::is_nothrow_constructible_v< index_type, IndexTypes >), int > = 0, std::enable_if_t< std::is_constructible_v< M, E >, int > = 0, std::enable_if_t< std::is_default_constructible_v< A >, int > = 0> | |
constexpr | mdspan (data_handle_type p, IndexTypes... exts) |
Construct from the dynamic extents given as variadic list. | |
template<class IndexType , std::size_t N, std::enable_if_t< std::is_convertible_v< const IndexType &, index_type >, int > = 0, std::enable_if_t< std::is_nothrow_constructible_v< index_type, const IndexType & >, int > = 0, std::enable_if_t<(N==extents_type::rank_dynamic()||N==extents_type::rank()), int > = 0> | |
constexpr | mdspan (data_handle_type p, Std::span< IndexType, N > exts) |
Construct from the dynamic extents given as an array. | |
template<class IndexType , std::size_t N, std::enable_if_t< std::is_convertible_v< IndexType, index_type >, int > = 0, std::enable_if_t<(N==extents_type::rank_dynamic()||N==extents_type::rank()), int > = 0> | |
constexpr | mdspan (data_handle_type p, const std::array< IndexType, N > &exts) |
Construct from the dynamic extents given as an array. | |
template<class M = mapping_type, std::enable_if_t< std::is_constructible_v< M, const extents_type & >, int > = 0> | |
constexpr | mdspan (data_handle_type p, const extents_type &e) |
Construct from the pointer to the data of the tensor and its extents. | |
template<class A = accessor_type, std::enable_if_t< std::is_default_constructible_v< A >, int > = 0> | |
constexpr | mdspan (data_handle_type p, const mapping_type &m) |
Construct from the pointer to the data of the tensor and an index mapping. | |
constexpr | mdspan (data_handle_type p, const mapping_type &m, const accessor_type &a) |
Construct from the pointer to the data of the tensor, an index mapping, and an accessor. | |
template<class OtherElementType , class OtherExtends , class OtherLayoutPolicy , class OtherAccessor , std::enable_if_t< std::is_constructible_v< mapping_type, const typename OtherLayoutPolicy::template mapping< OtherExtends > & >, int > = 0, std::enable_if_t< std::is_constructible_v< accessor_type, const OtherAccessor & >, int > = 0> | |
constexpr | mdspan (const mdspan< OtherElementType, OtherExtends, OtherLayoutPolicy, OtherAccessor > &other) noexcept |
Converting constructor. | |
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, std::enable_if_t<(... &&std::is_nothrow_constructible_v< index_type, Indices >), int > = 0> | |
constexpr reference | operator() (Indices... indices) const |
Access specified element at position i0,i1,... More... | |
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) const |
Access specified element at position [i0] For a rank one mdspan, 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, std::enable_if_t< std::is_nothrow_constructible_v< index_type, const Index & >, int > = 0> | |
constexpr reference | operator[] (Std::span< Index, extents_type::rank()> indices) const |
Access specified element at position [i0,i1,...]. | |
template<class Index , std::enable_if_t< std::is_convertible_v< const Index &, index_type >, int > = 0, std::enable_if_t< std::is_nothrow_constructible_v< index_type, const Index & >, int > = 0> | |
constexpr reference | operator[] (const std::array< Index, extents_type::rank()> &indices) const |
Access specified element at position [i0,i1,...]. | |
Detailed Description
class Dune::Std::mdspan< Element, Extents, LayoutPolicy, AccessorPolicy >
A multi-dimensional non-owning array view.
The class mdspan
is a view into a contiguous sequence of objects that reinterprets it as a multidimensional array.
The implementation is based in the standard proposal P0009r17 and the C++ standard working draft N4971.
Example:
- Note
- The interface of
Std::mdspan
provides 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. AccessorPolicy Specifies how to convert underlying 1D index to a reference to Element
.
Member Function Documentation
◆ is_always_exhaustive()
|
inlinestaticconstexpr |
Return true only if for all k in the range [0, mapping.required_span_size() ) there exists an i such that mapping(i...) equals k.
◆ is_always_strided()
|
inlinestaticconstexpr |
Return true only if for every rank index r of extents there exists an integer sr such that, for all i where (i+dr) is a multidimensional index in extents, mapping((i+dr)...) - mapping(i...) equals sr. *.
- Note
- This implies that for a strided layout mapping(i0, ..., ik) = mapping(0, ..., 0) + i0 * s0 + ... + ik * sk.
◆ is_always_unique()
|
inlinestaticconstexpr |
Return true only if for every i and j where (i != j || ...) => mapping(i...) != mapping(j...).
◆ is_strided()
|
inlineconstexpr |
Return true only if for every rank index r of extents there exists an integer sr such that, for all i where (i+dr) is a multidimensional index in extents, mapping((i+dr)...) - mapping(i...) equals sr. *.
- Note
- This implies that for a strided layout mapping(i0, ..., ik) = mapping(0, ..., 0) + i0 * s0 + ... + ik * sk.
◆ operator()()
|
inlineconstexpr |
Access specified element at position i0,i1,...
- Note
- The
operator()
is not in the std proposal, but is provided for using mdspan without c++23.
The documentation for this class was generated from the following file:
- dune/common/std/mdspan.hh
