17 #ifndef OPENKALMAN_CLIP_SQUARE_SHAPED_HPP 18 #define OPENKALMAN_CLIP_SQUARE_SHAPED_HPP 26 template<std::size_t...Ix,
typename Arg>
27 constexpr decltype(
auto) clip_square_shaped_impl(
std::index_sequence<Ix...>, Arg&& arg)
29 auto dim = internal::smallest_vector_space_descriptor<scalar_type_of_t<Arg>>(get_index_dimension_of<0>(arg), get_index_dimension_of<1>(arg));
30 auto ret {
get_slice(std::forward<Arg>(arg),
31 std::forward_as_tuple(std::integral_constant<std::size_t,
static_cast<decltype(Ix)
>(0)>{}...),
32 std::forward_as_tuple((Ix==0?dim:dim)...))};
44 template<indexible Arg>
45 constexpr square_shaped<Applicability::permitted> decltype(
auto)
47 template<
typename Arg>
48 constexpr decltype(
auto)
50 clip_square_shaped(Arg&& arg)
52 if constexpr (square_shaped<Arg>)
return std::forward<Arg>(arg);
55 static_assert(index_count_v<Arg> <= 2);
56 return detail::clip_square_shaped_impl(std::make_index_sequence<index_count_v<Arg>>{}, std::forward<Arg>(arg));
62 #endif //OPENKALMAN_CLIP_SQUARE_SHAPED_HPP decltype(auto) constexpr get_slice(Arg &&arg, const std::tuple< Offset... > &offsets, const std::tuple< Extent... > &extents)
Extract a slice from a matrix or tensor.
Definition: get_slice.hpp:101
Definition: tuple_reverse.hpp:103
Definition: basics.hpp:48