17 #ifndef OPENKALMAN_DIAGONAL_OF_MDSPAN_POLICIES_HPP 18 #define OPENKALMAN_DIAGONAL_OF_MDSPAN_POLICIES_HPP 21 #include "patterns/patterns.hpp" 29 template<
typename NestedLayout,
typename NestedExtents>
32 template<
class Extents>
35 using extents_type = Extents;
36 using index_type =
typename extents_type::index_type;
37 using size_type =
typename extents_type::size_type;
38 using rank_type =
typename extents_type::rank_type;
43 using nested_extents_type = NestedExtents;
46 template<
typename...Is>
48 access_with_padded_indices(Is...is)
const 50 if constexpr (
sizeof...(Is) < nested_extents_type::rank())
51 return access_with_padded_indices(is..., 0_uz);
53 return nested_mapping_(is...);
59 mapping(
const nested_mapping_type& map,
const extents_type& e)
60 : nested_mapping_(map), extents_(e) {}
62 constexpr
const extents_type&
63 extents()
const noexcept {
return extents_; }
67 operator() ()
const requires (extents_type::rank() == 0)
69 template<
bool Enable = true, std::enable_if_t<Enable and (extents_type::rank() == 0),
int> = 0>
74 return access_with_padded_indices();
80 std::convertible_to<index_type>
auto i0,
81 std::convertible_to<index_type>
auto...is)
const requires (1 +
sizeof...(is) == extents_type::rank())
83 template<
typename IndexType0,
typename...IndexTypes, std::enable_if_t<
84 std::is_convertible_v<IndexType0, index_type> and
85 (... and std::is_convertible_v<IndexTypes, index_type>) and
86 (1 +
sizeof...(IndexTypes) == extents_type::rank()),
int> = 0>
88 operator() (IndexType0 i0, IndexTypes...is)
const 91 return access_with_padded_indices(i0, i0, is...);
95 required_span_size()
const noexcept {
return nested_mapping_.required_span_size(); }
97 static constexpr
bool is_always_unique() noexcept {
return nested_mapping_type::is_always_unique(); }
100 is_always_exhaustive() noexcept
102 if constexpr (not nested_mapping_type::is_always_exhaustive())
return false;
103 else if constexpr (nested_extents_type::rank() == 0)
return true;
104 else if constexpr (nested_extents_type::rank() == 1)
return nested_extents_type::static_extent(0) == 1;
105 else return nested_extents_type::static_extent(0) == 1 and nested_extents_type::static_extent(1) == 1;
108 static constexpr
bool 109 is_always_strided() noexcept {
return nested_mapping_type::is_always_strided(); }
112 is_unique()
const {
return nested_mapping_type::is_unique(); }
115 is_exhaustive()
const 117 if (not nested_mapping_type::is_exhaustive())
return false;
118 if constexpr (nested_extents_type::rank() == 0)
return true;
119 else if constexpr (nested_extents_type::rank() == 1)
return nested_mapping_.extents().extent(0) == 1;
120 else return nested_mapping_.extents().extent(0) == 1 and nested_mapping_.extents().extent(1) == 1;
124 is_strided()
const {
return nested_mapping_type::is_strided(); }
127 stride(std::size_t r)
const 129 if (r == 0)
return nested_mapping_.stride(0) + nested_mapping_.stride(1);
130 return nested_mapping_.stride(r - 1);
133 template<
class OtherExtents>
134 friend constexpr
bool 142 nested_mapping_type nested_mapping_;
143 extents_type extents_;
Definition: basics.hpp:41
Definition: diagonal_of_mdspan_policies.hpp:33
constexpr auto compare_pattern_collections(const A &a, const B &b)
Compare each element of two pattern_collection objects lexicographically.
Definition: compare_pattern_collections.hpp:137
Definition: diagonal_of_mdspan_policies.hpp:30