1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:07:34 +00:00

AK+Everywhere: Add sincos and use it in some places

Calculating sin and cos at once is quite a bit cheaper than calculating
them individually.
x87 has even a dedicated instruction for it: `fsincos`.
This commit is contained in:
Hendiadyoin1 2022-02-03 12:48:17 +01:00 committed by Andreas Kling
parent 47fe911196
commit cd21e03225
6 changed files with 30 additions and 10 deletions

View file

@ -55,7 +55,9 @@ public:
template<AK::Concepts::Arithmetic U, AK::Concepts::Arithmetic V>
static constexpr Complex<T> from_polar(U magnitude, V phase)
{
return Complex<T>(magnitude * cos(phase), magnitude * sin(phase));
V s, c;
sincos(phase, s, c);
return Complex<T>(magnitude * c, magnitude * s);
}
template<AK::Concepts::Arithmetic U>