17 #ifndef OPENKALMAN_MAKE_CONSTANT_DIAGONAL_FROM_DESCRIPTORS_HPP 18 #define OPENKALMAN_MAKE_CONSTANT_DIAGONAL_FROM_DESCRIPTORS_HPP 30 template<
typename T,
typename C,
typename Descriptors>
31 static constexpr decltype(
auto)
32 make_constant_diagonal_from_descriptors(C&& c, Descriptors&& descriptors)
34 if constexpr (coordinates::pattern_tuple<Descriptors>)
36 auto new_descriptors = std::tuple_cat(
37 std::tuple(internal::smallest_vector_space_descriptor<scalar_type_of_t<T>>(
38 std::get<0>(std::forward<Descriptors>(descriptors)), std::get<1>(std::forward<Descriptors>(descriptors)))),
40 return make_constant<T>(std::forward<C>(c), new_descriptors);
44 #if __cpp_lib_containers_ranges >= 202202L and __cpp_lib_ranges_concat >= 202403L 45 auto new_indices = std::views::concat(
46 internal::smallest_vector_space_descriptor<scalar_type_of_t<T>>(std::ranges::views::take(indices, 2)),
47 indices | std::ranges::views::drop(2));
49 #ifdef __cpp_lib_ranges 50 namespace ranges = std::ranges;
52 auto it = ranges::begin(descriptors);
53 auto new_descriptors = std::vector<std::decay_t<decltype(*it)>>{};
56 if (i1 == end(descriptors))
58 new_descriptors.emplace_back(coordinates::Axis{});
60 else if (i0 != end(descriptors))
62 auto d0 = internal::smallest_vector_space_descriptor<scalar_type_of_t<T>>(*i0, *i1);
63 new_descriptors.emplace_back(d0);
64 std::copy(++it, ranges::end(descriptors), ++ranges::begin(new_descriptors));
67 return make_constant<T>(std::forward<C>(c), new_descriptors);
73 #endif //OPENKALMAN_MAKE_CONSTANT_DIAGONAL_FROM_DESCRIPTORS_HPP Definition for coordinates::pattern.
constexpr auto tuple_slice(Arg &&arg)
Takes a slice of a tuple, given an index range.
Definition: tuple_slice.hpp:132
Definition for pattern_tuple.
Definition: basics.hpp:48