12namespace di::math::detail {
14 template<concepts::FloatingPo
int T>
15 constexpr static auto operator()(T x) -> T {
16 auto as_bytes = di::bit_cast<di::Array<
byte,
sizeof(T)>>(x);
18 if constexpr (Endian::Little == Endian::Native) {
24 return (msb &
byte(0b1000'0000)) !=
byte(0);
27 template<concepts::Integral T>
28 constexpr static auto operator()(T x) ->
bool {
29 return Signbit::operator()(
f64(x));
35constexpr inline auto signbit = math::detail::Signbit {};
38namespace di::math::detail {
40 template<concepts::FloatingPo
int T>
41 constexpr static auto operator()(T x, T y) -> T {
44 auto as_bytes = di::bit_cast<di::Array<
byte,
sizeof(T)>>(x);
45 auto& msb = [&] ->
byte& {
46 if constexpr (Endian::Little == Endian::Native) {
53 msb &= ~(
byte(1) << 7);
54 msb |= (
byte(sign) << 7);
59 template<concepts::Integral T>
60 constexpr static auto operator()(T x, T y) ->
f64 {
61 return Copysign::operator()(
f64(x),
f64(y));
67constexpr inline auto copysign = math::detail::Copysign {};
70namespace di::math::detail {
72 template<concepts::FloatingPo
int T>
73 constexpr static auto operator()(T x) -> T {
76 return -Round::operator()(-x);
79 return T(
i64(x + 0.5));
82 template<concepts::Integral T>
83 constexpr static auto operator()(T x) ->
f64 {
84 return Round::operator()(
f64(x));
90constexpr inline auto round = math::detail::Round {};
93namespace di::math::detail {
95 template<concepts::FloatingPo
int T>
96 constexpr static auto operator()(T x, T y) -> T {
98 auto quotient =
round(x / y);
99 return x - quotient * y;
102 template<concepts::Integral T>
103 constexpr static auto operator()(T x, T y) ->
f64 {
104 return Remainder::operator()(
f64(x),
f64(y));
110constexpr inline auto remainder = math::detail::Remainder {};
113namespace di::math::detail {
115 template<concepts::FloatingPo
int T>
116 constexpr static auto operator()(T x, T y) -> T {
125 template<concepts::Integral T>
126 constexpr static auto operator()(T x, T y) ->
f64 {
127 return Fmod::operator()(
f64(x),
f64(y));
133constexpr inline auto fmod = math::detail::Fmod {};
136namespace di::math::detail {
138 template<concepts::FloatingPo
int T>
139 constexpr static auto operator()(T x) -> T;
141 template<concepts::Integral T>
142 constexpr static auto operator()(T x) ->
f64 {
143 return Cos::operator()(
f64(x));
148 template<concepts::FloatingPo
int T>
149 constexpr static auto operator()(T x) -> T;
151 template<concepts::Integral T>
152 constexpr static auto operator()(T x) ->
f64 {
153 return Sin::operator()(
f64(x));
157template<concepts::FloatingPo
int T>
158constexpr auto Cos::operator()(T x) -> T {
183 return T(1.0) - x * x / T(2.0) + x * x * x * x / T(24.0) - x * x * x * x * x * x / T(720.0);
186template<concepts::FloatingPo
int T>
187constexpr auto Sin::operator()(T x) -> T {
190 return -Sin::operator()(-x);
213 return x - x * x * x / T(6.0) + x * x * x * x * x / T(120.0);
218constexpr inline auto cos = math::detail::Cos {};
219constexpr inline auto sin = math::detail::Sin {};
222namespace di::math::detail {
223struct ApproximatelyEqual {
224 template<concepts::FloatingPo
int T>
225 constexpr static auto operator()(T x, T y, T epsilon = 0.0001) {
226 return x >= y - epsilon && x <= y + epsilon;
constexpr auto abs
Definition abs.h:39
constexpr auto pi_v
Definition constants.h:21
std::byte byte
Definition byte.h:64
double f64
Definition floats.h:5
__INT64_TYPE__ i64
Definition integers.h:17
Definition any_storable.h:9
constexpr auto sin
Definition functions.h:219
constexpr auto signbit
Definition functions.h:35
constexpr auto approximately_equal
Definition functions.h:232
constexpr auto as_bytes
Definition as_bytes.h:16
constexpr auto remainder
Definition functions.h:110
constexpr auto fmod
Definition functions.h:133
constexpr auto round
Definition functions.h:90
constexpr auto copysign
Definition functions.h:67
constexpr auto cos
Definition functions.h:218