17 #ifndef OPENKALMAN_SMALLEST_PATTERN_HPP 18 #define OPENKALMAN_SMALLEST_PATTERN_HPP 29 template<std::size_t i = 0,
typename P,
30 typename MI = std::integral_constant<std::size_t, 0>,
31 typename Min = std::integral_constant<std::size_t, std::numeric_limits<std::size_t>::max()>>
33 smallest_pattern_fixed(
const P& p, MI mi = {}, Min min = {})
35 if constexpr (i < collections::size_of_v<P>)
37 auto ix = std::integral_constant<std::size_t, i>{};
40 auto select = [](
bool q, std::size_t curr, std::size_t old){
return q ? curr : old; };
41 return smallest_pattern_fixed<i + 1>(
61 template<pattern_collection P> requires collections::sized<P> and
62 (collections::size_of_v<P> == stdex::dynamic_extent or collections::size_of_v<P> > 0_uz)
65 template<
typename P, std::enable_if_t<pattern_collection<P> and collections::sized<P> and
66 (collections::size_of<P>::value == stdex::dynamic_extent or collections::size_of<P>::value > 0_uz),
int> = 0>
69 smallest_pattern(
const P& p)
71 if constexpr (collections::size_of_v<P> == stdex::dynamic_extent)
74 decltype(
auto) pr = collections::views::all(p);
75 #ifdef __cpp_lib_ranges 76 auto it = std::ranges::min_element(pr, fn);
78 auto it = std::min_element(pr.begin(), pr.end(), fn);
80 return static_cast<std::size_t
>(std::distance(pr.begin(), it));
84 return detail::smallest_pattern_fixed(p);
Definition for pattern_collection.
Definition: get_descriptor_dimension.hpp:25
Definition for coordinates::pattern.
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of coordinates::pattern Arg.
Definition: get_dimension.hpp:54
Inclusion file for collections.
constexpr bool index
T is an index value.
Definition: index.hpp:62
constexpr auto operation(Operation &&op, Args &&...args)
A potentially constant-evaluated operation involving some number of values.
Definition: operation.hpp:98