17 #ifndef OPENKALMAN_PATTERNS_DIAGONAL_OF_HPP 18 #define OPENKALMAN_PATTERNS_DIAGONAL_OF_HPP 22 #include "patterns/descriptors/Any.hpp" 41 template<pattern_collection R> requires
47 pattern_collection_element_t<1, R>,
48 pattern_collection_element_t<0, R>,
52 template<
typename R, std::enable_if_t<
53 pattern_collection<R> and
55 pattern_collection_element_t<0, R>,
56 pattern_collection_element_t<1, R>,
59 pattern_collection_element_t<1, R>,
60 pattern_collection_element_t<0, R>,
62 constexpr decltype(
auto)
64 operator() (R&& r)
const 66 using N2 = std::integral_constant<std::size_t, 2>;
67 using P0 = pattern_collection_element_t<0, R>;
68 using P1 = pattern_collection_element_t<1, R>;
72 return std::forward<R>(r);
78 else if constexpr (compares_with<P0, P1, &stdex::is_lteq>)
81 std::array {get_pattern<0>(r)},
84 else if constexpr (compares_with<P0, P1, &stdex::is_gt>)
87 std::array {get_pattern<1>(r)},
92 auto p0 = get_pattern<0>(r);
93 auto p1 = get_pattern<1>(r);
96 if (compare<&stdex::is_lteq>(p0, p1))
98 if (compare<&stdex::is_gt>(p0, p1))
100 throw (std::logic_error(
"Patterns for the first two ranks are not compatible for taking diagonal"));
115 #ifdef __cpp_concepts 116 template<pattern_collection R> requires
122 pattern_collection_element_t<1, R>,
123 pattern_collection_element_t<0, R>,
127 template<
typename R, std::enable_if_t<
128 pattern_collection<R> and
130 pattern_collection_element_t<0, R>,
131 pattern_collection_element_t<1, R>,
134 pattern_collection_element_t<1, R>,
135 pattern_collection_element_t<0, R>,
137 constexpr decltype(
auto)
139 operator() (R&& r)
const Definition for pattern_collection.
constexpr bool pattern_collection
An object describing a sized collection of /ref sized_pattern objects.
Definition: pattern_collection.hpp:66
constexpr detail::concat_adaptor concat
a std::ranges::range_adaptor_closure for a set of concatenated collection objects.
Definition: concat.hpp:209
Definition for compares_with.
The concept, trait, or restraint is permitted, but whether it applies is not necessarily known at com...
constexpr bool compares_with
Compares two patterns::pattern objects.
Definition: compares_with.hpp:472
The namespace for views for patterns::pattern object.
Definition: patterns.hpp:51
Definition of the Dimensions class.
Definition for patterns::get_pattern.
The size of a sized object (including a collection).
Definition: size_of.hpp:33
A structure representing the dimensions associated with of a particular index.
Definition: Dimensions.hpp:42
typename pattern_collection_element< i, T >::type pattern_collection_element_t
Helper template for collection_element.
Definition: pattern_collection_element.hpp:58
Definition: diagonal_of.hpp:36
Inclusion file for collections.
constexpr detail::slice_adapter slice
a RangeAdapterObject associated with slice_view.
Definition: slice.hpp:423
Definition: range_adaptor_closure.hpp:34
constexpr detail::diagonal_of_adapter diagonal_of
A RangeAdapterObject that converts one pattern_collection to another corresponding to the diagonal_ma...
Definition: diagonal_of.hpp:153
constexpr bool fixed_value_compares_with
T has a fixed value that compares with N in a particular way based on parameter comp.
Definition: fixed_value_compares_with.hpp:74
Definition: diagonal_of.hpp:106
Definition for collections::pattern_collection_element.