batmat 0.0.18
Batched linear algebra routines
Loading...
Searching...
No Matches
shift.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <type_traits>
5
6namespace batmat::linalg {
7
8template <int I>
9struct with_shift_A_t : std::integral_constant<int, I> {};
10template <int I>
11struct with_rotate_B_t : std::integral_constant<int, I> {};
12template <int I>
13struct with_rotate_C_t : std::integral_constant<int, I> {};
14template <int I>
15struct with_rotate_D_t : std::integral_constant<int, I> {};
16template <int I>
17struct with_mask_D_t : std::integral_constant<int, I> {};
18
19template <int I>
21template <int I>
23template <int I>
25template <int I>
27template <int I>
29
30template <class...>
31inline constexpr std::optional<int> shift_A = std::nullopt;
32template <class T, class... Ts>
33inline constexpr std::optional<int> shift_A<T, Ts...> = shift_A<Ts...>;
34template <int I, class... Ts>
35inline constexpr std::optional<int> shift_A<with_shift_A_t<I>, Ts...> = I;
36
37template <class...>
38inline constexpr std::optional<int> rotate_B = std::nullopt;
39template <class T, class... Ts>
40inline constexpr std::optional<int> rotate_B<T, Ts...> = rotate_B<Ts...>;
41template <int I, class... Ts>
42inline constexpr std::optional<int> rotate_B<with_rotate_B_t<I>, Ts...> = I;
43
44template <class...>
45inline constexpr std::optional<int> rotate_C = std::nullopt;
46template <class T, class... Ts>
47inline constexpr std::optional<int> rotate_C<T, Ts...> = rotate_C<Ts...>;
48template <int I, class... Ts>
49inline constexpr std::optional<int> rotate_C<with_rotate_C_t<I>, Ts...> = I;
50
51template <class...>
52inline constexpr std::optional<int> rotate_D = std::nullopt;
53template <class T, class... Ts>
54inline constexpr std::optional<int> rotate_D<T, Ts...> = rotate_D<Ts...>;
55template <int I, class... Ts>
56inline constexpr std::optional<int> rotate_D<with_rotate_D_t<I>, Ts...> = I;
57
58template <class...>
59inline constexpr std::optional<int> mask_D = std::nullopt;
60template <class T, class... Ts>
61inline constexpr std::optional<int> mask_D<T, Ts...> = mask_D<Ts...>;
62template <int I, class... Ts>
63inline constexpr std::optional<int> mask_D<with_mask_D_t<I>, Ts...> = I;
64
65template <class>
66inline constexpr bool is_shift_opt = false;
67template <int I>
68inline constexpr bool is_shift_opt<with_shift_A_t<I>> = true;
69template <int I>
70inline constexpr bool is_shift_opt<with_rotate_B_t<I>> = true;
71template <int I>
72inline constexpr bool is_shift_opt<with_rotate_C_t<I>> = true;
73template <int I>
74inline constexpr bool is_shift_opt<with_rotate_D_t<I>> = true;
75template <int I>
76inline constexpr bool is_shift_opt<with_mask_D_t<I>> = true;
77
78template <class Opt>
80
81template <int I>
82struct with_rotate_t : std::integral_constant<int, I> {};
83template <int I>
84struct with_mask_t : std::integral_constant<int, I> {};
85
86template <int I>
88template <int I>
89inline constexpr with_mask_t<I> with_mask;
90
91template <class...>
92inline constexpr std::optional<int> get_rotate = std::nullopt;
93template <class T, class... Ts>
94inline constexpr std::optional<int> get_rotate<T, Ts...> = get_rotate<Ts...>;
95template <int I, class... Ts>
96inline constexpr std::optional<int> get_rotate<with_rotate_t<I>, Ts...> = I;
97
98template <class...>
99inline constexpr std::optional<int> get_mask = std::nullopt;
100template <class T, class... Ts>
101inline constexpr std::optional<int> get_mask<T, Ts...> = get_mask<Ts...>;
102template <int I, class... Ts>
103inline constexpr std::optional<int> get_mask<with_mask_t<I>, Ts...> = I;
104
105template <class>
106inline constexpr bool is_rotate_opt = false;
107template <int I>
108inline constexpr bool is_rotate_opt<with_rotate_t<I>> = true;
109template <int I>
110inline constexpr bool is_rotate_opt<with_mask_t<I>> = true;
111
112template <class Opt>
114
115} // namespace batmat::linalg
constexpr bool is_rotate_opt
Definition shift.hpp:106
constexpr with_mask_t< I > with_mask
Definition shift.hpp:89
constexpr with_rotate_D_t< I > with_rotate_D
Definition shift.hpp:26
constexpr with_rotate_t< I > with_rotate
Definition shift.hpp:87
constexpr with_shift_A_t< I > with_shift_A
Definition shift.hpp:20
constexpr std::optional< int > rotate_B
Definition shift.hpp:38
constexpr with_rotate_B_t< I > with_rotate_B
Definition shift.hpp:22
constexpr std::optional< int > rotate_C
Definition shift.hpp:45
constexpr with_mask_D_t< I > with_mask_D
Definition shift.hpp:28
constexpr std::optional< int > mask_D
Definition shift.hpp:59
constexpr bool is_shift_opt
Definition shift.hpp:66
constexpr std::optional< int > get_rotate
Definition shift.hpp:92
constexpr std::optional< int > get_mask
Definition shift.hpp:99
constexpr std::optional< int > rotate_D
Definition shift.hpp:52
constexpr with_rotate_C_t< I > with_rotate_C
Definition shift.hpp:24
constexpr std::optional< int > shift_A
Definition shift.hpp:31