15template<
typename T, std::
size_t N>
18template<
typename T, std::
size_t N>
21template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
24 static constexpr std::size_t
n_dim =
N;
25 template<
typename R =
T,
typename F,
typename ...Args>
26 static constexpr CRTP<R>
map(F
f, Args &&...args);
27 template<
typename R =
T,
typename F, std::size_t ...I>
29 F
f, std::index_sequence<I...>,
const vec &
v);
30 template<
typename R =
T,
typename F, std::size_t ...I>
32 F
f, std::index_sequence<I...>,
T t,
const vec &v0);
33 template<
typename R =
T,
typename F, std::size_t ...I>
35 F
f, std::index_sequence<I...>,
const vec &v0,
T t);
36 template<
typename R =
T,
typename F, std::size_t ...I>
38 F
f, std::index_sequence<I...>,
const vec &v0,
const vec &v1);
39 template<
typename U>
explicit constexpr operator CRTP<U>(
void)
const;
52 template<std::
size_t I>
constexpr T &
get(
void);
53 template<std::
size_t I>
constexpr const T &
get(
void)
const;
55 constexpr const T *
data(
void)
const;
59template<
template<
typename>
typename T,
typename U>
64template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
65template<
typename R,
typename F,
typename ...Args>
70template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
71template<
typename R,
typename F, std::size_t ...I>
73 F
f, std::index_sequence<I...>,
const vec &
v)
75 return {
static_cast<R
>(
f(
v.get<I>()))...};
78template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
79template<
typename R,
typename F, std::size_t ...I>
81 F
f, std::index_sequence<I...>,
T t,
const vec &
v)
83 return {
static_cast<R
>(
f(t,
v.get<I>()))...};
86template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
87template<
typename R,
typename F, std::size_t ...I>
89 F
f, std::index_sequence<I...>,
const vec &
v,
T t)
91 return {
static_cast<R
>(
f(
v.get<I>(), t))...};
94template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
95template<
typename R,
typename F, std::size_t ...I>
97 F
f, std::index_sequence<I...>,
const vec &v0,
const vec &v1)
99 return {
static_cast<R
>(
f(v0.
get<I>(), v1.
get<I>()))...};
102template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
105 return vec::map<U>([](
auto x) {
return static_cast<U
>(x); }, *
this);
108template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
110 std::memcpy(
this, &
v,
sizeof(CRTP<T>));
return *
this;
113template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
115 return this->
data()[
i];
118template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
120 return const_cast<T&
>(
static_cast<const vec&
>(*this)[
i]);
123template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
125 return vec::map(std::negate<>(), *
this);
128template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
130 auto &d =
static_cast<CRTP<T>&
>(*this);
return d = d + t;
133template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
135 auto &d =
static_cast<CRTP<T>&
>(*this);
return d = d - t;
138template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
140 auto &d =
static_cast<CRTP<T>&
>(*this);
return d = d * t;
143template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
145 auto &d =
static_cast<CRTP<T>&
>(*this);
return d = d / t;
148template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
150 auto &d =
static_cast<CRTP<T>&
>(*this);
return d = d +
v;
153template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
155 auto &d =
static_cast<CRTP<T>&
>(*this);
return d = d -
v;
158template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
160 auto &d =
static_cast<CRTP<T>&
>(*this);
return d = d *
v;
163template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
165 auto &d =
static_cast<CRTP<T>&
>(*this);
return d = d /
v;
168template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
170 static_assert(I <
N);
171 auto *p =
static_cast<const CRTP<T>*
>(
this);
174 else if constexpr(I == 1)
176 else if constexpr(I == 2)
178 else if constexpr(I == 3)
182template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
183template<std::
size_t I>
185 return const_cast<T&
>(
static_cast<const vec*
>(
this)->
get<I>());
188template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
190 return [
this]<std::size_t ...I>(std::index_sequence<I...>) {
191 return std::tuple{
static_cast<const CRTP<T>&
>(*this)[I]...};
192 }(std::make_index_sequence<N>());
195template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
197 return &
static_cast<CRTP<T>&
>(*this).x;
200template<
template<
typename>
typename CRTP,
typename T, std::size_t
N>
202 return &
static_cast<const CRTP<T>&
>(*this).x;
205template<
template<
typename>
typename T,
typename R>
209template<
template<
typename>
typename T,
typename R>
211inline constexpr const R *
end(
const T<R> &
v) {
return &
v[T<R>::n_dim]; }
213template<
template<
typename>
typename T,
typename R>
217template<
template<
typename>
typename T,
typename R>
219inline constexpr R *
end(
T<R> &
v) {
return &
v[T<R>::n_dim]; }
221template<
template<
typename>
typename T,
typename R>
227template<
template<
typename>
typename T,
typename R>
233template<
template<
typename>
typename T,
typename R>
236 return T<R>::map(std::plus<>(),
s,
v);
239template<
template<
typename>
typename T,
typename R>
242 return T<R>::map(std::minus<>(),
s,
v);
245template<
template<
typename>
typename T,
typename R>
248 return T<R>::map(std::multiplies<>(),
s,
v);
251template<
template<
typename>
typename T,
typename R>
254 return T<R>::map(std::divides<>(),
s,
v);
257template<
template<
typename>
typename T,
typename R>
260 return T<R>::map(std::plus<>(),
v,
s);
263template<
template<
typename>
typename T,
typename R>
266 return T<R>::map(std::minus<>(),
v,
s);
269template<
template<
typename>
typename T,
typename R>
272 return T<R>::map(std::multiplies<>(),
v,
s);
275template<
template<
typename>
typename T,
typename R>
278 return T<R>::map(std::divides<>(),
v,
s);
281template<
template<
typename>
typename T,
typename R>
284 return T<R>::map(std::plus<>(), v0, v1);
287template<
template<
typename>
typename T,
typename R>
290 return T<R>::map(std::minus<>(), v0, v1);
293template<
template<
typename>
typename T,
typename R>
296 return T<R>::map(std::multiplies<>(), v0, v1);
299template<
template<
typename>
typename T,
typename R>
302 return T<R>::map(std::divides<>(), v0, v1);
function DEMO text end
Definition demo0.lua:6
for i
Definition font.lua:5
local N
Definition gamma.lua:5
local data
Definition house0.lua:10
constexpr const R * begin(const T< R > &v)
Definition vec.h:207
constexpr T< R > operator-(R s, const T< R > &v)
Definition vec.h:241
constexpr bool operator!=(const T< R > &v0, const T< R > &v1)
Definition vec.h:229
constexpr T< R > operator/(R s, const T< R > &v)
Definition vec.h:253
constexpr bool operator==(const mat< CRTP, T, N > &m0, const mat< CRTP, T, N > &m1)
Definition mat.h:57
typename vec_type< T, N >::type vec_type_t
Definition vec.h:19
constexpr T< R > operator+(R s, const T< R > &v)
Definition vec.h:235
typename T::type vector_type
Definition vec.h:62
constexpr CRTP< T > operator*(T s, const mat< CRTP, T, N > &m)
Definition mat.h:65
#define F(...)
Definition pp.cpp:12
get
Definition camera.lua:46
v[1]
Definition math.lua:22
#define FWD(...)
Definition utils.h:18
static constexpr CRTP< R > map_impl(F f, std::index_sequence< I... >, const vec &v0, const vec &v1)
Definition vec.h:96
T type
Definition vec.h:23
constexpr CRTP< T > & operator*=(T t)
Definition vec.h:139
constexpr CRTP< T > & operator+=(const CRTP< T > &v)
Definition vec.h:149
static constexpr CRTP< R > map_impl(F f, std::index_sequence< I... >, const vec &v0, T t)
Definition vec.h:88
constexpr CRTP< T > & operator-=(const CRTP< T > &v)
Definition vec.h:154
constexpr CRTP< T > & operator/=(T t)
Definition vec.h:144
constexpr T * data(void)
Definition vec.h:196
constexpr const T * data(void) const
Definition vec.h:201
static constexpr CRTP< R > map_impl(F f, std::index_sequence< I... >, T t, const vec &v0)
Definition vec.h:80
constexpr T & operator[](std::size_t i)
Definition vec.h:119
constexpr CRTP< T > operator-(void) const
Definition vec.h:124
constexpr CRTP< T > & operator/=(const CRTP< T > &v)
Definition vec.h:164
static constexpr CRTP< R > map_impl(F f, std::index_sequence< I... >, const vec &v)
Definition vec.h:72
constexpr vec & operator=(const CRTP< T > &v)
Definition vec.h:109
constexpr auto as_tuple(void) const
Definition vec.h:189
constexpr T & get(void)
Definition vec.h:184
constexpr CRTP< T > & operator+=(T t)
Definition vec.h:129
constexpr CRTP< T > & operator-=(T t)
Definition vec.h:134
static constexpr std::size_t n_dim
Definition vec.h:24
constexpr const T & get(void) const
Definition vec.h:169
constexpr CRTP< T > & operator*=(const CRTP< T > &v)
Definition vec.h:159
static constexpr CRTP< R > map(F f, Args &&...args)
Definition vec.h:66
constexpr const T & operator[](std::size_t i) const
Definition vec.h:114
std::chrono::seconds s
Definition timing.cpp:6