BAN: Implement sincos to math

This function calculates both sin and cos fast (hopefully)
This commit is contained in:
Bananymous 2024-11-04 17:41:35 +02:00
parent a82f00cb70
commit 346853ee55
1 changed files with 6 additions and 3 deletions

View File

@ -325,7 +325,6 @@ namespace BAN::Math
template<floating_point T>
inline constexpr T sin(T x)
{
x = fmod<T>(x, (T)2.0 * numbers::pi_v<T>);
asm("fsin" : "+t"(x));
return x;
}
@ -333,12 +332,16 @@ namespace BAN::Math
template<floating_point T>
inline constexpr T cos(T x)
{
if (abs(x) >= (T)9223372036854775808.0)
x = fmod<T>(x, (T)2.0 * numbers::pi_v<T>);
asm("fcos" : "+t"(x));
return x;
}
template<floating_point T>
inline constexpr void sincos(T x, T& sin, T& cos)
{
asm("fsincos" : "=t"(cos), "=u"(sin) : "0"(x));
}
template<floating_point T>
inline constexpr T tan(T x)
{