dune-common 2.10
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Related Symbols | List of all members
Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container > Class Template Reference

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_typemapping () const noexcept
 Index mapping of a layout policy.
 
constexpr const container_typecontainer () 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
 

Related Symbols

(Note that these are not member symbols.)

constexpr const extents_typeextents () const noexcept
 Number of elements in all dimensions of the array,.
 

Conversion into mdspan

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.
 

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< 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.
 

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
// same two-dimensional array but with dynamic shape
// storage type similar to the Dune::FieldMatrix
template <class T, int m, int 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]
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
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
ElementThe element type; a complete object type that is neither an abstract class type nor an array type.
ExtentsSpecifies number of dimensions, their sizes, and which are known at compile time. Must be a specialization of Std::extents.
LayoutPolicySpecifies how to convert multi-dimensional index to underlying flat index.
ContainerA 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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( )
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( IndexTypes...  exts)
inlineexplicitconstexpr

Construct from the dynamic extents.

◆ mdarray() [3/22]

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const extents_type e)
inlineexplicitconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mapping_type m)
inlineexplicitconstexpr

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>>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const extents_type e,
const value_type v 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mapping_type m,
const value_type v 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const E &  e,
const container_type c 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const E &  e,
container_type &&  c 
)
inlineconstexpr

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>>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mapping_type m,
const container_type c 
)
inlineconstexpr

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>>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mapping_type m,
container_type &&  c 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mdarray< OtherElementType, OtherExtents, OtherLayoutPolicy, OtherContainer > &  other)
inlineconstexpr

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< 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 Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mdspan< OtherElementType, OtherExtents, OtherLayoutPolicy, Accessor > &  other)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const extents_type e,
const Alloc &  a 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mapping_type m,
const Alloc &  a 
)
inlineconstexpr

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 >
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const extents_type e,
const value_type v,
const Alloc &  a 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mapping_type m,
const value_type v,
const Alloc &  a 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const extents_type e,
const container_type c,
const Alloc &  a 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const extents_type e,
container_type &&  c,
const Alloc &  a 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mapping_type m,
const container_type c,
const Alloc &  a 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mapping_type m,
container_type &&  c,
const Alloc &  a 
)
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mdarray< V, E, L, C > &  other,
const Alloc &  a 
)
inlineconstexprnoexcept

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mdarray ( const mdspan< V, E, L, A > &  other,
const Alloc &  a 
)
inlineconstexpr

Converting constructor from mdspan.

Member Function Documentation

◆ container()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
constexpr const container_type & Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container ( ) const
inlineconstexprnoexcept

The underlying storage container.

◆ container_data() [1/2]

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
constexpr const_pointer Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container_data ( ) const
inlineconstexprnoexcept

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>>
constexpr pointer Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container_data ( )
inlineconstexprnoexcept

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>>
constexpr std::size_t Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::container_size ( ) const
inlineconstexpr

Size of the underlying container.

◆ empty()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
constexpr bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::empty ( ) const
inlineconstexprnoexcept

Check whether the index space is empty.

◆ extent()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
constexpr index_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::extent ( rank_type  r) const
inlineconstexprnoexcept

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>>
constexpr container_type && Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::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()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
static constexpr bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::is_always_exhaustive ( )
inlinestaticconstexprnoexcept

◆ is_always_strided()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
static constexpr bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::is_always_strided ( )
inlinestaticconstexprnoexcept

◆ is_always_unique()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
static constexpr bool Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::is_always_unique ( )
inlinestaticconstexprnoexcept

◆ is_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_exhaustive ( ) const
inlineconstexprnoexcept

◆ is_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_strided ( ) const
inlineconstexprnoexcept

◆ is_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_unique ( ) const
inlineconstexprnoexcept

◆ mapping()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
constexpr const mapping_type & Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mapping ( ) const
inlineconstexprnoexcept

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator mdspan< V, E, L, A > ( )
inlineconstexpr

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>
constexpr Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator mdspan< V, E, L, A > ( ) const
inlineconstexpr

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>
constexpr reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator() ( Indices...  indices)
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]

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>
constexpr const_reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator() ( Indices...  indices) const
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]

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>
constexpr reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] ( const std::array< Index, extents_type::rank()> &  indices)
inlineconstexpr

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>
constexpr const_reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] ( const std::array< Index, extents_type::rank()> &  indices) const
inlineconstexpr

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>
constexpr reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] ( Index  index)
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]

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>
constexpr const_reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] ( Index  index) const
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]

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>
constexpr reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] ( Std::span< Index, extents_type::rank()>  indices)
inlineconstexpr

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>
constexpr const_reference Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[] ( Std::span< Index, extents_type::rank()>  indices) const
inlineconstexpr

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

◆ rank()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
static constexpr rank_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::rank ( )
inlinestaticconstexprnoexcept

Number of dimensions of the array.

◆ rank_dynamic()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
static constexpr rank_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::rank_dynamic ( )
inlinestaticconstexprnoexcept

Number of dimension with dynamic size.

◆ size()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
constexpr size_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::size ( ) const
inlineconstexprnoexcept

Size of the multi-dimensional index space.

◆ static_extent()

template<class Element , class Extents , class LayoutPolicy = Std::layout_right, class Container = std::vector<Element>>
static constexpr std::size_t Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::static_extent ( rank_type  r)
inlinestaticconstexprnoexcept

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>>
constexpr index_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::stride ( rank_type  r) const
inlineconstexpr

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>
constexpr mdspan< element_type, extents_type, layout_type, AccessorPolicy > Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::to_mdspan ( const AccessorPolicy &  a = AccessorPolicy{})
inlineconstexpr

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>
constexpr mdspan< const element_type, extents_type, layout_type, AccessorPolicy > Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::to_mdspan ( const AccessorPolicy &  a = AccessorPolicy{}) const
inlineconstexpr

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>>
constexpr const extents_type & extents ( ) const
related

Number of elements in all dimensions of the array,.

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>>
mapping_type Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::mapping_
protected

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