44#if defined(TIMEMORY_WINDOWS)
45 const Tp _infv = std::numeric_limits<Tp>::infinity();
46 const Tp _inf = (val < 0.0) ? -_infv : _infv;
47 return (val == val && val != _inf);
54TIMEMORY_INLINE Tp
abs(Tp);
57TIMEMORY_INLINE Tp
sqrt(Tp);
64TIMEMORY_INLINE Tp
sqr(Tp);
68min(
const Tp&,
const Tp&);
72max(
const Tp&,
const Tp&);
74template <
typename Tp,
typename Up = Tp>
78template <
typename Tp,
typename Up = Tp,
83template <
typename Tp,
typename Up = Tp,
86 minus(Tp&,
const Up&);
88template <
typename Tp,
typename Up = Tp,
93template <
typename Tp,
typename Up = Tp,
112template <
typename Tp,
size_t N,
typename Other>
116template <
typename Lhs,
typename Rhs,
typename Other>
120template <
typename Tp,
typename... _Extra,
typename Other>
121std::vector<Tp, _Extra...>&
124template <
typename... Types,
typename Other>
134template <
typename Tp,
size_t N>
136operator-=(std::array<Tp, N>&,
const std::array<Tp, N>&);
138template <
typename Lhs,
size_t N,
typename Rhs,
143template <
typename Lhs,
typename Rhs>
145operator-=(std::pair<Lhs, Rhs>&,
const std::pair<Lhs, Rhs>&);
147template <
typename Lhs,
typename Rhs,
typename ArithT,
152template <
typename Tp,
typename... _Extra>
153std::vector<Tp, _Extra...>&
154operator-=(std::vector<Tp, _Extra...>&,
const std::vector<Tp, _Extra...>&);
156template <
typename Lhs,
typename Rhs,
typename... _Extra,
158std::vector<Lhs, _Extra...>&
161template <
typename... Types>
163operator-=(std::tuple<Types...>&,
const std::tuple<Types...>&);
165template <
typename... Lhs,
typename Rhs,
176template <
typename Tp,
size_t N>
178operator*=(std::array<Tp, N>&,
const std::array<Tp, N>&);
180template <
typename Lhs,
size_t N,
typename Rhs,
185template <
typename Lhs,
typename Rhs>
187operator*=(std::pair<Lhs, Rhs>&,
const std::pair<Lhs, Rhs>&);
189template <
typename Lhs,
typename Rhs,
typename ArithT,
192operator*=(std::pair<Lhs, Rhs>&,
const ArithT&);
194template <
typename Tp,
typename... _Extra>
195std::vector<Tp, _Extra...>&
196operator*=(std::vector<Tp, _Extra...>&,
const std::vector<Tp, _Extra...>&);
198template <
typename Lhs,
typename Rhs,
typename... _Extra,
200std::vector<Lhs, _Extra...>&
203template <
typename... Types>
205operator*=(std::tuple<Types...>&,
const std::tuple<Types...>&);
207template <
typename... Lhs,
typename Rhs,
218template <
typename Tp,
size_t N>
220operator/=(std::array<Tp, N>&,
const std::array<Tp, N>&);
222template <
typename Lhs,
size_t N,
typename Rhs,
227template <
typename Lhs,
typename Rhs>
229operator/=(std::pair<Lhs, Rhs>&,
const std::pair<Lhs, Rhs>&);
231template <
typename Lhs,
typename Rhs,
typename ArithT,
234operator/=(std::pair<Lhs, Rhs>&,
const ArithT&);
236template <
typename Tp,
typename... _Extra>
237std::vector<Tp, _Extra...>&
238operator/=(std::vector<Tp, _Extra...>&,
const std::vector<Tp, _Extra...>&);
240template <
typename Lhs,
typename Rhs,
typename... _Extra,
242std::vector<Lhs, _Extra...>&
245template <
typename... Types>
247operator/=(std::tuple<Types...>&,
const std::tuple<Types...>&);
249template <
typename... Lhs,
typename Rhs,
261template <
typename Lhs,
typename Rhs,
265template <
typename Lhs,
typename Rhs,
276template <
typename Tp,
size_t N>
278operator+(std::array<Tp, N> lhs,
const std::array<Tp, N>& rhs);
280template <
typename... Types>
282operator+(std::tuple<Types...> lhs,
const std::tuple<Types...>& rhs);
284template <
typename Lhs,
typename Rhs>
286operator+(std::pair<Lhs, Rhs> lhs,
const std::pair<Lhs, Rhs>& rhs);
288template <
typename Tp,
typename... Extra>
289std::vector<Tp, Extra...>
290operator+(std::vector<Tp, Extra...> lhs,
const std::vector<Tp, Extra...>& rhs);
298template <
typename Tp,
size_t N>
300operator-(std::array<Tp, N> lhs,
const std::array<Tp, N>& rhs);
302template <
typename... Types>
304operator-(std::tuple<Types...> lhs,
const std::tuple<Types...>& rhs);
306template <
typename Lhs,
typename Rhs>
308operator-(std::pair<Lhs, Rhs> lhs,
const std::pair<Lhs, Rhs>& rhs);
310template <
typename Tp,
typename... Extra>
311std::vector<Tp, Extra...>
312operator-(std::vector<Tp, Extra...> lhs,
const std::vector<Tp, Extra...>& rhs);
320template <
typename Tp,
size_t N>
321std::array<Tp, N>
operator*(std::array<Tp, N> lhs,
const std::array<Tp, N>& rhs);
323template <
typename... Types>
324std::tuple<Types...>
operator*(std::tuple<Types...> lhs,
const std::tuple<Types...>& rhs);
326template <
typename Lhs,
typename Rhs>
327std::pair<Lhs, Rhs>
operator*(std::pair<Lhs, Rhs> lhs,
const std::pair<Lhs, Rhs>& rhs);
329template <
typename Tp,
typename... Extra>
330std::vector<Tp, Extra...>
operator*(std::vector<Tp, Extra...> lhs,
331 const std::vector<Tp, Extra...>& rhs);
339template <
typename Tp,
size_t N>
341operator/(std::array<Tp, N> lhs,
const std::array<Tp, N>& rhs);
343template <
typename... Types>
345operator/(std::tuple<Types...> lhs,
const std::tuple<Types...>& rhs);
347template <
typename Lhs,
typename Rhs>
349operator/(std::pair<Lhs, Rhs> lhs,
const std::pair<Lhs, Rhs>& rhs);
351template <
typename Tp,
typename... Extra>
352std::vector<Tp, Extra...>
353operator/(std::vector<Tp, Extra...> lhs,
const std::vector<Tp, Extra...>& rhs);
361#define TIMEMORY_MATH_NULL_TYPE_OVERLOAD(TYPE) \
366 TIMEMORY_INLINE TYPE abs(TYPE) { return TYPE{}; } \
367 TIMEMORY_INLINE TYPE sqrt(TYPE) { return TYPE{}; } \
368 TIMEMORY_INLINE TYPE pow(TYPE, double) { return TYPE{}; } \
369 TIMEMORY_INLINE TYPE sqr(TYPE) { return TYPE{}; } \
370 TIMEMORY_INLINE TYPE min(const TYPE&, const TYPE&) { return TYPE{}; } \
371 TIMEMORY_INLINE TYPE max(const TYPE&, const TYPE&) { return TYPE{}; } \
372 TIMEMORY_INLINE void assign(TYPE&, TYPE&&) {} \
373 TIMEMORY_INLINE TYPE& plus(TYPE& lhs, const TYPE&) { return lhs; } \
374 TIMEMORY_INLINE TYPE& minus(TYPE& lhs, const TYPE&) { return lhs; } \
375 TIMEMORY_INLINE TYPE& multiply(TYPE& lhs, const TYPE&) { return lhs; } \
376 TIMEMORY_INLINE TYPE& divide(TYPE& lhs, const TYPE&) { return lhs; } \
377 TIMEMORY_INLINE TYPE percent_diff(const TYPE&, const TYPE&) { return TYPE{}; } \
378 template <typename Up> \
379 TIMEMORY_INLINE TYPE& plus(TYPE& lhs, Up&&) \
383 template <typename Up> \
384 TIMEMORY_INLINE TYPE& minus(TYPE& lhs, Up&&) \
388 template <typename Up> \
389 TIMEMORY_INLINE TYPE& multiply(TYPE& lhs, Up&&) \
393 template <typename Up> \
394 TIMEMORY_INLINE TYPE& divide(TYPE& lhs, Up&&) \
398 TIMEMORY_INLINE TYPE& divide(TYPE& lhs, uint64_t) { return lhs; } \
399 TIMEMORY_INLINE TYPE& divide(TYPE& lhs, int64_t) { return lhs; } \
407#if defined(TIMEMORY_WINDOWS)
410template <
typename Lhs,
typename Rhs>
412operator-(pair<Lhs, Rhs>,
const pair<Lhs, Rhs>&);
414template <
typename... Types>
416operator-(tuple<Types...>,
const tuple<Types...>&);
#define TIMEMORY_MATH_NULL_TYPE_OVERLOAD(TYPE)
Tp max(const Tp &, const Tp &)
Tp min(const Tp &, const Tp &)
type_list abs(type_list<>)
Tp & plus(Tp &, const Up &)
type_list sqr(type_list<>)
auto divide(Tp &_lhs, Up _rhs, type_list<>,...) -> decltype(_lhs/=_rhs, void())
void assign(Tp &_lhs, Up &&_rhs)
Tp & minus(Tp &, const Up &)
Tp & multiply(Tp &, const Up &)
Tp percent_diff(const Tp &, const Tp &)
bool is_finite(const Tp &val)
type_list sqrt(type_list<>)
std::vector< Tp, Extra... > operator-(std::vector< Tp, Extra... > lhs, const std::vector< Tp, Extra... > &rhs)
std::array< Tp, N > & operator+=(std::array< Tp, N > &, Other &&)
std::array< Tp, N > & operator/=(std::array< Tp, N > &, const std::array< Tp, N > &)
std::array< Tp, N > operator-(std::array< Tp, N > lhs, const std::array< Tp, N > &rhs)
Lhs operator/(Lhs, const Rhs &)
Lhs operator*(Lhs, const Rhs &)
std::array< Tp, N > & operator*=(std::array< Tp, N > &, const std::array< Tp, N > &)
std::array< Tp, N > & operator-=(std::array< Tp, N > &, const std::array< Tp, N > &)
std::array< Tp, N > operator+(std::array< Tp, N > lhs, const std::array< Tp, N > &rhs)
typename std::enable_if< B, T >::type enable_if_t
Alias template for enable_if.
bool isfinite(const Tp &arg)
lightweight tuple-alternative for meta-programming logic
this is a placeholder type for optional type-traits. It is used as the default type for the type-trai...