Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::layout_left::mapping< Extents > Class Template Reference

A mapping from a logical pack of indices into a single flat physical output index. More...

Inheritance diagram for arene::base::layout_left::mapping< Extents >:
Inheritance graph

Public Types

using layout_type = layout_left
 The tag type of the layout used by this mapping.
 

Public Member Functions

constexpr mapping () noexcept
 Construct a default left-strided mapping for the given extents.
 
constexpr mapping (extents_type const &exts) noexcept
 Construct a left-strided mapping for the given extents.
 
template<typename OtherExtents>
constexpr mapping (layout_right::mapping< OtherExtents > const &other) noexcept
 Converting constructor from a layout_right::mapping when both have 0- or 1-dimensional extents.
 
template<typename OtherExtents>
constexpr mapping (layout_right::mapping< OtherExtents > const &other) noexcept
 Converting constructor from a layout_right::mapping when both have 0- or 1-dimensional extents.
 
template<typename OtherExtents, constraints< std::enable_if_t< std::is_constructible< extents_type, OtherExtents >::value >, std::enable_if_t< OtherExtents::rank()==rank_type{0U}> > = nullptr>
constexpr mapping (layout_stride::mapping< OtherExtents > const &other) noexcept
 Converting constructor from a layout_stride::mapping with a compatible extents_type.
 
template<typename OtherExtents, constraints< std::enable_if_t< std::is_constructible< extents_type, OtherExtents >::value >, std::enable_if_t<(OtherExtents::rank() > rank_type{0U})>>
constexpr mapping (layout_stride::mapping< OtherExtents > const &other) noexcept
 Converting constructor from a layout_stride::mapping with a compatible extents_type.
 
template<typename OtherExtents, constraints< std::enable_if_t< std::is_convertible< OtherExtents, extents_type >::value > > = nullptr>
constexpr mapping (mapping< OtherExtents > const &other) noexcept
 Converting constructor from a mapping with a different (but compatible) extents_type.
 
template<typename OtherExtents, constraints< std::enable_if_t< std::is_constructible< extents_type, OtherExtents >::value >, std::enable_if_t<!std::is_convertible< OtherExtents, extents_type >::value > > = nullptr>
constexpr mapping (mapping< OtherExtents > const &other) noexcept
 Converting constructor from a mapping with a different (but compatible) extents_type.
 

Static Public Member Functions

static constexpr auto is_always_exhaustive () noexcept -> bool
 Return whether or not this mapping is always exhaustive, i.e. every element is reachable using some indices.
 
static constexpr auto is_exhaustive () noexcept -> bool
 Return whether or not this instance is exhaustive, i.e. every element is reachable using some indices.
 

Friends

template<typename OtherExtents, constraints< std::enable_if_t< extents_type::rank()==OtherExtents::rank()> > = nullptr>
constexpr auto operator!= (mapping const &left, mapping< OtherExtents > const &right) noexcept -> bool
 Compare two left-strided mappings for inequality.
 
template<typename OtherExtents, constraints< std::enable_if_t< extents_type::rank()==OtherExtents::rank()> > = nullptr>
constexpr auto operator== (mapping const &left, mapping< OtherExtents > const &right) noexcept -> bool
 Compare two left-strided mappings for equality.
 
template<class... CanonicalSliceSpecifiers, constraints< std::enable_if_t< sizeof...(CanonicalSliceSpecifiers)==extents_type::rank()>, std::enable_if_t< mdspan_detail::all_valid_submdspan_slice_types_for_v< extents_type, CanonicalSliceSpecifiers... > > > = nullptr>
constexpr auto submdspan_mapping (mapping const &src, CanonicalSliceSpecifiers... slices) noexcept -> CanonicalSliceSpecifiers... > >(mdspan_detail::is_submdspan_layout_preserving< layout_left, submdspan_subextents_type_t< extents_type, CanonicalSliceSpecifiers... >::rank(), CanonicalSliceSpecifiers... >{}, src, mapping::passkey(), mapping::strides_of(src), std::move(slices)...))
 Compute the sub-mapping for a layout_left::mapping.
 

Detailed Description

template<class Extents>
class arene::base::layout_left::mapping< Extents >

A mapping from a logical pack of indices into a single flat physical output index.

Template Parameters
Theextents of the space used for this mapping; must be a specialization of extents

Member Typedef Documentation

◆ layout_type

template<class Extents>
using arene::base::layout_left::mapping< Extents >::layout_type = layout_left

The tag type of the layout used by this mapping.

Constructor & Destructor Documentation

◆ mapping() [1/8]

template<class Extents>
arene::base::layout_left::mapping< Extents >::mapping ( )
inlineconstexprnoexcept

Construct a default left-strided mapping for the given extents.

◆ mapping() [2/8]

template<class Extents>
arene::base::layout_left::mapping< Extents >::mapping ( extents_type const & exts)
inlineconstexprnoexcept

Construct a left-strided mapping for the given extents.

Parameters
extsThe extents to use
Precondition
The size of the index space represented by exts fits within index_type, else ARENE_PRECONDITION violation

◆ mapping() [3/8]

template<class Extents>
template<typename OtherExtents, constraints< std::enable_if_t< std::is_convertible< OtherExtents, extents_type >::value > > = nullptr>
arene::base::layout_left::mapping< Extents >::mapping ( mapping< OtherExtents > const & other)
inlineconstexprnoexcept

Converting constructor from a mapping with a different (but compatible) extents_type.

Note
This is implicit if and only if OtherExtents is implicitly convertible to extents_type
Template Parameters
OtherExtentsType of other's extents
Parameters
otherThe other layout_left::mapping
Precondition
other.required_span_size() can be represented as a value of this type's index_type, else ARENE_PRECONDITION violation

◆ mapping() [4/8]

template<class Extents>
template<typename OtherExtents, constraints< std::enable_if_t< std::is_constructible< extents_type, OtherExtents >::value >, std::enable_if_t<!std::is_convertible< OtherExtents, extents_type >::value > > = nullptr>
arene::base::layout_left::mapping< Extents >::mapping ( mapping< OtherExtents > const & other)
inlineexplicitconstexprnoexcept

Converting constructor from a mapping with a different (but compatible) extents_type.

Note
This is implicit if and only if OtherExtents is implicitly convertible to extents_type
Template Parameters
OtherExtentsType of other's extents
Parameters
otherThe other layout_left::mapping
Precondition
other.required_span_size() can be represented as a value of this type's index_type, else ARENE_PRECONDITION violation

◆ mapping() [5/8]

template<class Extents>
template<typename OtherExtents>
arene::base::layout_left::mapping< Extents >::mapping ( layout_right::mapping< OtherExtents > const & other)
inlineconstexprnoexcept

Converting constructor from a layout_right::mapping when both have 0- or 1-dimensional extents.

Note
This is implicit if and only if OtherExtents is implicitly convertible to extents_type
Template Parameters
OtherExtentsType of other's extents
Parameters
otherThe layout_right::mapping
Precondition
other.required_span_size() can be represented as a value of this type's index_type, else ARENE_PRECONDITION violation

◆ mapping() [6/8]

template<class Extents>
template<typename OtherExtents>
arene::base::layout_left::mapping< Extents >::mapping ( layout_right::mapping< OtherExtents > const & other)
inlineexplicitconstexprnoexcept

Converting constructor from a layout_right::mapping when both have 0- or 1-dimensional extents.

Note
This is implicit if and only if OtherExtents is implicitly convertible to extents_type
Template Parameters
OtherExtentsType of other's extents
Parameters
otherThe layout_right::mapping
Precondition
other.required_span_size() can be represented as a value of this type's index_type, else ARENE_PRECONDITION violation

◆ mapping() [7/8]

template<class Extents>
template<typename OtherExtents, constraints< std::enable_if_t< std::is_constructible< extents_type, OtherExtents >::value >, std::enable_if_t< OtherExtents::rank()==rank_type{0U}> > = nullptr>
arene::base::layout_left::mapping< Extents >::mapping ( layout_stride::mapping< OtherExtents > const & other)
inlineconstexprnoexcept

Converting constructor from a layout_stride::mapping with a compatible extents_type.

Note
This is implicit if and only if OtherExtents::rank() == 0
Template Parameters
OtherExtentsType of other's extents
Parameters
otherThe layout_stride::mapping
Precondition
other.required_span_size() can be represented as a value of this type's index_type, else ARENE_PRECONDITION violation
other's strides are exactly those of a layout_right::mapping with its extents, else ARENE_PRECONDITION violation

◆ mapping() [8/8]

template<class Extents>
template<typename OtherExtents, constraints< std::enable_if_t< std::is_constructible< extents_type, OtherExtents >::value >, std::enable_if_t<(OtherExtents::rank() > rank_type{0U})>>
arene::base::layout_left::mapping< Extents >::mapping ( layout_stride::mapping< OtherExtents > const & other)
inlineexplicitconstexprnoexcept

Converting constructor from a layout_stride::mapping with a compatible extents_type.

Note
This is implicit if and only if OtherExtents::rank() == 0
Template Parameters
OtherExtentsType of other's extents
Parameters
otherThe layout_stride::mapping
Precondition
other.required_span_size() can be represented as a value of this type's index_type, else ARENE_PRECONDITION violation
other's strides are exactly those of a layout_right::mapping with its extents, else ARENE_PRECONDITION violation

Member Function Documentation

◆ is_always_exhaustive()

template<class Extents>
static constexpr auto arene::base::layout_left::mapping< Extents >::is_always_exhaustive ( ) -> bool
inlinestaticconstexprnoexcept

Return whether or not this mapping is always exhaustive, i.e. every element is reachable using some indices.

Returns
true because the mapping is always computed by a simple invertible left-strided algorithm
Note
In mathematical terms this asks if the mapping is always surjective/onto.

◆ is_exhaustive()

template<class Extents>
static constexpr auto arene::base::layout_left::mapping< Extents >::is_exhaustive ( ) -> bool
inlinestaticconstexprnoexcept

Return whether or not this instance is exhaustive, i.e. every element is reachable using some indices.

Returns
true if every provided stride is the product of the extents corresponding to some subset of the other strides, otherwise false
Note
In mathematical terms this asks if the mapping is surjective/onto.

Friends And Related Symbol Documentation

◆ operator!=

template<class Extents>
template<typename OtherExtents, constraints< std::enable_if_t< extents_type::rank()==OtherExtents::rank()> > = nullptr>
auto operator!= ( mapping< Extents > const & left,
mapping< OtherExtents > const & right ) -> bool
friend

Compare two left-strided mappings for inequality.

Template Parameters
OtherExtentsThe type of the extents used by the right-hand side of the comparison
Parameters
leftAn instance of layout_left::mapping
rightAn instance of layout_left::mapping<OtherExtents>
Returns
true if left and right have unequal extents

◆ operator==

template<class Extents>
template<typename OtherExtents, constraints< std::enable_if_t< extents_type::rank()==OtherExtents::rank()> > = nullptr>
auto operator== ( mapping< Extents > const & left,
mapping< OtherExtents > const & right ) -> bool
friend

Compare two left-strided mappings for equality.

Template Parameters
OtherExtentsThe type of the extents used by the right-hand side of the comparison
Parameters
leftAn instance of layout_left::mapping
rightAn instance of layout_left::mapping<OtherExtents>
Returns
true if left and right have equal extents

◆ submdspan_mapping

template<class Extents>
template<class... CanonicalSliceSpecifiers, constraints< std::enable_if_t< sizeof...(CanonicalSliceSpecifiers)==extents_type::rank()>, std::enable_if_t< mdspan_detail::all_valid_submdspan_slice_types_for_v< extents_type, CanonicalSliceSpecifiers... > > > = nullptr>
auto submdspan_mapping ( mapping< Extents > const & src,
CanonicalSliceSpecifiers... slices ) -> CanonicalSliceSpecifiers...>>( mdspan_detail::is_submdspan_layout_preserving< layout_left, submdspan_subextents_type_t<extents_type, CanonicalSliceSpecifiers...>::rank(), CanonicalSliceSpecifiers...>{}, src, mapping::passkey(), mapping::strides_of(src), std::move(slices)... ))
friend

Compute the sub-mapping for a layout_left::mapping.

Template Parameters
CanonicalSliceSpecifierstypes of the slice specifiers, one per dimension
Parameters
srcthe source mapping to slice
slicesthe slice specifiers

Uses slices to compute the sub-extents, sub-strides, and offset of the submdspan. The slices must be in canonical form.

Returns
A submdspan_mapping_result containing the sub-mapping and offset such that indexing the sub-mapping and adding the offset recovers the corresponding index in the original mapping.
Note
Constraints
  • sizeof...(CanonicalSliceSpecifiers) == extents_type::rank()
  • for each rank index k of src.extents(), CanonicalSliceSpecifiers...[k] is a valid submdspan slice type for the k-th extent of extents_type
Preconditions
  • for each rank index k of src.extents(), slices...[k] denotes a valid submdspan slice for the k-th extent of src.extents()
Remarks
  • the layout_left specialization of submdspan_mapping produces a layout_left::mapping if:
    • for each k in the range [0, SubExtents::rank() - 1) , CanonicalSliceSpecifiers...[k] denotes full_extent_t; and
    • for k equal to SubExtents::rank() - 1 , CanonicalSliceSpecifiers...[k] is a unit-stride slice type;
  • Otherwise, it produces a layout_stride::mapping.

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