Loading...
Searching...
No Matches
Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container > Class Template Reference
Common » Utilities » C++ utilities and backports

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

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:

// two-dimensional array with 2 rows and 6 columns of static shape
Dune::Std::mdarray<double, Dune::Std::extents<std::size_t,2,6>> m1{};
// same two-dimensional array but with dynamic shape
Dune::Std::mdarray<double, Dune::Std::dextents<std::size_t,2>> m2{2,6};
// storage type similar to the Dune::FieldMatrix
template <class T, int m, int n>
using FieldMatrix = Dune::Std::mdarray<T,
Dune::Std::extents<int,m,n>, Dune::Std::layout_right, std::array<T,m*n>>;
// store data into the array using two indices
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; // or m1[i, j]
Dune::FieldMatrix
A dense n x m matrix.
Definition fmatrix.hh:117
Dune::Std::extents
Multidimensional index space with dynamic and static extents.
Definition extents.hh:55
Dune::Std::layout_right
A layout where the rightmost extent has stride 1, and strides increase right-to-left as the product o...
Definition fwd_layouts.hh:30
Dune::Std::mdarray
An owning multi-dimensional array analog of mdspan.
Definition mdarray.hh:69
Dune::Std::mdarray::extent
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.

## Member Typedef Documentation

## const_mdspan_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::const_mdspan_type = mdspan<const element_type,extents_type,layout_type>

## const_pointer

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::const_pointer = decltype(std::to_address(std::declval<container_type>().cbegin()))

## const_reference

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::const_reference = typename container_type::const_reference

## container_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container_type = Container

## element_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::element_type = Element

## extents_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::extents_type = Extents

## index_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::index_type = typename extents_type::index_type

## layout_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::layout_type = LayoutPolicy

## mapping_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mapping_type = typename layout_type::template mapping<extents_type>

## mdspan_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdspan_type = mdspan<element_type,extents_type,layout_type>

## pointer

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::pointer = decltype(std::to_address(std::declval<container_type>().begin()))

## rank_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::rank_type = typename extents_type::rank_type

## reference

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::reference = typename container_type::reference

## size_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::size_type = typename extents_type::size_type

## value_type

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

using Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::value_type = element_type

## Constructor & Destructor Documentation

## mdarray() [1/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( |  | ) |

inline constexpr

A default constructor; needed only if the constructor for dynamic extents does not apply.

## mdarray() [2/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | IndexTypes... | exts | ) |

inline explicit constexpr

Construct from the dynamic extents.

## mdarray() [3/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const extents_type & | e | ) |

inline explicit constexpr

Construct from the extents of the array.

## mdarray() [4/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class C = container_type, decltype(construct_container< C >(std::declval< std::size_t >()), bool{}) = true>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mapping_type & | m | ) |

inline explicit constexpr

Construct from the layout mapping of the array.

## mdarray() [5/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const extents_type & | e,
|  | const value_type & | v )

inline constexpr

Construct from extents and initial value.

## mdarray() [6/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class C = container_type, decltype(construct_container< C >(std::declval< std::size_t >(), std::declval< const value_type & >()), bool{}) = true>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mapping_type & | m,
|  | const value_type & | v )

inline constexpr

Construct from layout mapping and initial value.

## mdarray() [7/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class E = extents_type, std::enable_if_t< std::is_constructible_v< mapping_type, const E & >, int > = 0>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const E & | e,
|  | const container_type & | c )

inline constexpr

Construct from extents and the storage container.

## mdarray() [8/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class E = extents_type, std::enable_if_t< std::is_constructible_v< mapping_type, const E & >, int > = 0>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const E & | e,
|  | container_type && | c )

inline constexpr

Construct from extents and the storage container.

## mdarray() [9/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mapping_type & | m,
|  | const container_type & | c )

inline constexpr

Construct from layout mapping and the storage container.

## mdarray() [10/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mapping_type & | m,
|  | container_type && | c )

inline constexpr

Construct from layout mapping and the storage container.

## mdarray() [11/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mdarray< OtherElementType, OtherExtents, OtherLayoutPolicy, OtherContainer > & | other | ) |

inline constexpr

Converting constructor from other mdarray.

## mdarray() [12/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mdspan< OtherElementType, OtherExtents, OtherLayoutPolicy, Accessor > & | other | ) |

inline constexpr

Converting constructor from mdspan.

## mdarray() [13/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, std::size_t, Alloc >, int > = 0>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const extents_type & | e,
|  | const Alloc & | a )

inline constexpr

Construct from the extents of the array and allocator.

## mdarray() [14/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, std::size_t, Alloc >, int > = 0>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mapping_type & | m,
|  | const Alloc & | a )

inline constexpr

Construct from the layout mapping of the array and allocator.

## mdarray() [15/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Alloc>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const extents_type & | e,
|  | const value_type & | v,
|  | const Alloc & | a )

inline constexpr

Construct from extents, initial value and allocator.

## mdarray() [16/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, std::size_t, value_type, Alloc >, int > = 0>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mapping_type & | m,
|  | const value_type & | v,
|  | const Alloc & | a )

inline constexpr

Construct from layout mapping, initial value and allocator.

## mdarray() [17/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, container_type, Alloc >, int > = 0>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const extents_type & | e,
|  | const container_type & | c,
|  | const Alloc & | a )

inline constexpr

Construct from extents, container and allocator.

## mdarray() [18/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, container_type, Alloc >, int > = 0>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const extents_type & | e,
|  | container_type && | c,
|  | const Alloc & | a )

inline constexpr

Construct from extents, container and allocator.

## mdarray() [19/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, container_type, Alloc >, int > = 0>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mapping_type & | m,
|  | const container_type & | c,
|  | const Alloc & | a )

inline constexpr

Construct from layout mapping, container and allocator.

## mdarray() [20/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Alloc, std::enable_if_t< std::is_constructible_v< container_type, container_type, Alloc >, int > = 0>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mapping_type & | m,
|  | container_type && | c,
|  | const Alloc & | a )

inline constexpr

Construct from layout mapping, container and allocator.

## mdarray() [21/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mdarray< V, E, L, C > & | other,
|  | const Alloc & | a )

inline constexpr noexcept

Converting constructor with alternative allocator.

## mdarray() [22/22]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray | ( | const mdspan< V, E, L, A > & | other,
|  | const Alloc & | a )

inline constexpr

Converting constructor from mdspan.

## Member Function Documentation

## container()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

const container_type & Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container | ( |  | ) | const

inline constexpr noexcept

The underlying storage container.

## container_data() [1/2]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

const_pointer Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container_data | ( |  | ) | const

inline constexpr noexcept

Direct access to the underlying const data in the container.

## container_data() [2/2]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

pointer Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container_data | ( |  | ) |

inline constexpr noexcept

Direct access to the underlying data in the container.

## container_size()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

std::size_t Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container_size | ( |  | ) | const

inline constexpr

Size of the underlying container.

## empty()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::empty | ( |  | ) | const

inline nodiscard constexpr noexcept

Check whether the index space is empty.

## extent()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

index_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::extent | ( | rank_type | r | ) | const

inline constexpr noexcept

Number of elements in the r'th dimension of the tensor.

## extract_container()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

container_type && Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::extract_container | ( |  | ) | &&

inline constexpr noexcept

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()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

constexpr bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::is_always_exhaustive | ( |  | ) |

inline static constexpr noexcept

## is_always_strided()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

constexpr bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::is_always_strided | ( |  | ) |

inline static constexpr noexcept

## is_always_unique()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

constexpr bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::is_always_unique | ( |  | ) |

inline static constexpr noexcept

## is_exhaustive()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::is_exhaustive | ( |  | ) | const

inline constexpr noexcept

## is_strided()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::is_strided | ( |  | ) | const

inline constexpr noexcept

## is_unique()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::is_unique | ( |  | ) | const

inline constexpr noexcept

## mapping()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

const mapping_type & Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mapping | ( |  | ) | const

inline constexpr noexcept

Index mapping of a layout policy.

## operator mdspan< V, E, L, A >() [1/2]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator mdspan< V, E, L, A > | ( |  | ) |

inline constexpr

Conversion operator to mdspan.

## operator mdspan< V, E, L, A >() [2/2]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator mdspan< V, E, L, A > | ( |  | ) | const

inline constexpr

Conversion operator to mdspan.

## operator()() [1/2]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator() | ( | Indices... | indices | ) |

inline constexpr

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]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

const_reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator() | ( | Indices... | indices | ) | const

inline constexpr

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]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Index, std::enable_if_t< std::is_convertible_v< const Index &, index_type >, int > = 0>

reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] | ( | const std::array< Index, extents_type::rank()> & | indices | ) |

inline constexpr

Access element at position [{i0,i1,...}].

## operator[]() [2/6]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Index, std::enable_if_t< std::is_convertible_v< const Index &, index_type >, int > = 0>

const_reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] | ( | const std::array< Index, extents_type::rank()> & | indices | ) | const

inline constexpr

Access element at position [{i0,i1,...}].

## operator[]() [3/6]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] | ( | Index | index | ) |

inline constexpr

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]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

const_reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] | ( | Index | index | ) | const

inline constexpr

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]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Index, std::enable_if_t< std::is_convertible_v< const Index &, index_type >, int > = 0>

reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] | ( | std::span< Index, extents_type::rank()> | indices | ) |

inline constexpr

Access element at position [{i0,i1,...}].

## operator[]() [6/6]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class Index, std::enable_if_t< std::is_convertible_v< const Index &, index_type >, int > = 0>

const_reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] | ( | std::span< Index, extents_type::rank()> | indices | ) | const

inline constexpr

Access element at position [{i0,i1,...}].

## rank()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

constexpr rank_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::rank | ( |  | ) |

inline static constexpr noexcept

Number of dimensions of the array.

## rank_dynamic()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

constexpr rank_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::rank_dynamic | ( |  | ) |

inline static constexpr noexcept

Number of dimension with dynamic size.

## size()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

size_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::size | ( |  | ) | const

inline constexpr noexcept

Size of the multi-dimensional index space.

## static_extent()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

constexpr std::size_t Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::static_extent | ( | rank_type | r | ) |

inline static constexpr noexcept

Number of elements in the r'th dimension of the tensor.

## stride()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

index_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::stride | ( | rank_type | r | ) | const

inline constexpr

The stride along the specified dimension.

## to_mdspan() [1/2]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

mdspan< element_type, extents_type, layout_type, AccessorPolicy > Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::to_mdspan | ( | const AccessorPolicy & | a = AccessorPolicy{} | ) |

inline constexpr

Conversion function to mdspan.

## to_mdspan() [2/2]

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
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>

mdspan< const element_type, extents_type, layout_type, AccessorPolicy > Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::to_mdspan | ( | const AccessorPolicy & | a = AccessorPolicy{} | ) | const

inline constexpr

Conversion function to mdspan.

## Friends And Related Symbol Documentation

## extents()

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

const extents_type & extents | ( |  | ) | const

related

Number of elements in all dimensions of the array,.

## mdarray

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
template<class, class, class, class>

friend class mdarray

friend

## operator==

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

bool operator== | ( | const mdarray< Element, Extents, LayoutPolicy, Container > & | lhs,
|  | const mdarray< Element, Extents, LayoutPolicy, Container > & | rhs )

friend

## swap

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

void swap | ( | mdarray< Element, Extents, LayoutPolicy, Container > & | x,
|  | mdarray< Element, Extents, LayoutPolicy, Container > & | y )

friend

## Member Data Documentation

## container_

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

container_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container_

protected

## mapping_

template<class Element, class Extents, class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>

DUNE_NO_UNIQUE_ADDRESS mapping_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mapping_

protected

The documentation for this class was generated from the following file:

- mdarray.hh