summaryrefslogtreecommitdiff
path: root/AK/Math.h
AgeCommit message (Collapse)Author
2023-04-14AK: Make math work on arm hosts againNico Weber
957f89ce4abb6ad added some tweaks for serenity-on-aarch64. It broke anythingelse-on-aarch64 hosts though, so only do these tweaks when targeting serenity. (I wonder if AK/Math.h should fall back to the system math routines when not targeting serenity in general. Would probably help ladybird performance. On the other hand, the serenity routines would see less use and hence exposure and love.)
2023-04-13AK: Add very naive implementation of {sin,cos,tan} for aarch64Timon Kruiper
The {sin,cos,tan} functions in AK are used as the implementation of the same function in libm. We cannot use the __builtin_foo functions as these would just call the libc functions. This was causing an infinite loop. Fix this by adding a very naive implementation of AK::{sin, cos,tan}, that is only valid for small inputs. For the other functions in this file, I added a TODO() such that we'll crash, instead of infinite looping.
2023-03-10AK: Add constexpr floor and roundkleines Filmröllchen
2023-01-09AK: Reorder AK/Math after the removal of i686Hendiadyoin1
Without i686 we can remove some implementations for sqrt and round_to.
2022-12-28AK: Remove i686 supportLiav A
2022-11-26AK: Make it possible to not `using` AK classes into the global namespaceAndreas Kling
This patch adds the `USING_AK_GLOBALLY` macro which is enabled by default, but can be overridden by build flags. This is a step towards integrating Jakt and AK types.
2022-11-26AK: Fix double promotion error when using AK:ceil on floatsMacDue
2022-10-14AK: Fix aarch64 versions of math functionsHendiadyoin1
These were incorrectly assumed to compile, but did indeed still have a few issues.
2022-10-14AK: Add support for some trivial math functions on aarch64Hendiadyoin1
These all require just a single instruction each, we only have to differentiate between register prefixes accordingly.
2022-06-30AK: Add AK::ceil(float) and AK::ceil_log2(integer)MacDue
Co-authored-by: Leon Albrecht <leon2002.la@gmail.com>
2022-06-14AK: Add sqrt(2) and sqrt(1/2) constantsHediadyoin1
2022-05-08AK: Use AK:: sin and cos on aarch64 buildEWouters
This fixes the lagom build on aarch64, as `__builtin_sincosf` doesn't take double arguments.
2022-05-07AK: Use builtin versions of `llrint{,l,f}`EWouters
This fixes the build on M1 Macs.
2022-05-07AK: Add an SSE2 specific implementation of sqrt(double)Hendiadyoin1
2022-05-07AK: Add an helper for quick hardware based roundingHendiadyoin1
This uses the `fistp` and `cvts[sd]2si` respectively, to potentially round floating point values with just one instruction. This falls back to `llrint[fl]?` on aarch64 for now.
2022-04-23AK: Make sure we don't include Math.h or math.h from KERNELAndrew Kaster
2022-04-03AK: Add generic sincos solution for non-x86 platformsserenityosrocks
2022-04-02AK: Add rsqrt and a SSE specific implementation for sqrtHendiadyoin1
2022-03-15AK+Everywhere: Add sincos and use it in some placesHendiadyoin1
Calculating sin and cos at once is quite a bit cheaper than calculating them individually. x87 has even a dedicated instruction for it: `fsincos`.
2022-02-19AK: Don't use x86 assembly when building for non-x86 targetsGunnar Beutner
This allows Lagom to be built successfully for Apple M1. Fixes #12644.
2022-02-06AK: Move integral log2 and exp to IntegerMath.hHendiadyoin1
2022-01-29AK: Fix log2 calculation for IntegerPankaj Raghav
For a `N` bit integer X, the log2 calculation should be as follows: (N - 1) - ctz(X)
2021-12-21AK+Everywhere: Replace __builtin bit functionsNick Johnson
In order to reduce our reliance on __builtin_{ffs, clz, ctz, popcount}, this commit removes all calls to these functions and replaces them with the equivalent functions in AK/BuiltinWrappers.h.
2021-11-18AK: Implement `acos<T>` correctlyJelle Raaijmakers
This is a naive implementation based on the symmetry with `asin`. Before, I'm not really sure what we were doing, but it was returning wildly incorrect results.
2021-08-08AK: Handle partial remaindersDaniel Bertalan
On x86, the `fprem` and `fmprem1` instructions may produce a 'partial remainder', for which we should check by reading a FPU flag. If we don't check for it, we may end up using values that are outside the expected range of values.
2021-07-19AK: Introduce Math.hHendiadyoin1
This is to implement constexpr template based implementations for mathematical functions This also changes math.cpp to use these implementations. Also adds a fastpath for floating point trucation for values smaller than the signed 64 bit limit.