1 #ifndef EAGINE_VECT_AXIS_HPP
9 #define EAGINE_VECT_AXIS_HPP
13 namespace eagine::vect {
15 template <
typename T,
int N,
int I,
bool V>
17 static auto apply(T v) noexcept -> data_t<T, N, V> {
19 for(
int i = 0; i < N; ++i) {
20 r[i] = (i == I) ? v : T(0);
28 template <
typename T,
bool V>
29 struct axis<T, 1, 0, V> {
30 static constexpr
auto apply(T v) noexcept {
31 return data_t<T, 1, V>{v};
35 template <
typename T,
int I,
bool V>
36 struct axis<T, 1, I, V> {
37 static constexpr
auto apply(T) noexcept {
38 return data_t<T, 1, V>{0};
42 template <
typename T,
bool V>
43 struct axis<T, 2, 0, V> {
44 static constexpr
auto apply(T v) noexcept {
45 return data_t<T, 2, V>{v, T(0)};
49 template <
typename T,
bool V>
50 struct axis<T, 2, 1, V> {
51 static constexpr
auto apply(T v) noexcept {
52 return data_t<T, 2, V>{T(0), v};
56 template <
typename T,
int I,
bool V>
57 struct axis<T, 2, I, V> {
58 static constexpr
auto apply(T) noexcept {
59 return data_t<T, 2, V>{T(0), T(0)};
63 template <
typename T,
bool V>
64 struct axis<T, 3, 0, V> {
65 static constexpr
auto apply(T v) noexcept {
66 return data_t<T, 3, V>{v, T(0), T(0)};
70 template <
typename T,
bool V>
71 struct axis<T, 3, 1, V> {
72 static constexpr
auto apply(T v) noexcept {
73 return data_t<T, 3, V>{T(0), v, T(0)};
77 template <
typename T,
bool V>
78 struct axis<T, 3, 2, V> {
79 static constexpr
auto apply(T v) noexcept {
80 return data_t<T, 3, V>{T(0), T(0), v};
84 template <
typename T,
int I,
bool V>
85 struct axis<T, 3, I, V> {
86 static constexpr
auto apply(T) noexcept {
87 return data_t<T, 3, V>{T(0), T(0), T(0)};
91 template <
typename T,
bool V>
92 struct axis<T, 4, 0, V> {
93 static constexpr
auto apply(T v) noexcept {
94 return data_t<T, 4, V>{v, T(0), T(0), T(0)};
98 template <
typename T,
bool V>
99 struct axis<T, 4, 1, V> {
100 static constexpr
auto apply(T v) noexcept {
101 return data_t<T, 4, V>{T(0), v, T(0), T(0)};
105 template <
typename T,
bool V>
106 struct axis<T, 4, 2, V> {
107 static constexpr
auto apply(T v) noexcept {
108 return data_t<T, 4, V>{T(0), T(0), v, T(0)};
112 template <
typename T,
bool V>
113 struct axis<T, 4, 3, V> {
114 static constexpr
auto apply(T v) noexcept {
115 return data_t<T, 4, V>{T(0), T(0), T(0), v};
119 template <
typename T,
int I,
bool V>
120 struct axis<T, 4, I, V> {
121 static constexpr
auto apply(T) noexcept {
122 return data_t<T, 4, V>{T(0), T(0), T(0), T(0)};
130 #endif // EAGINE_VECT_AXIS_HPP