summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibM
AgeCommit message (Collapse)Author
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.
2021-07-17LibM: Turn off builtins, fix tests & implementationPeter Bindels
While trying to port to Clang we found that the functions as implemented didn't actually work, and replacing them with a blatantly broken function also did not break the tests on the GCC build. It turns out we've been testing GCC's builtins by many tests. This removes the use of builtins for LibM's tests (so we test the whole function). It turns off the denormal test for scalbn (which was not implemented) and comments out the tgamma(0.5) test which is too inaccurate to be usable (and too complicated for me to fix). The gamma function was made accurate for all other test cases, and asin received two more layers of Taylor expansion to bring it within error margin for the tests.
2021-07-08Everywhere: Add Clang pragmasDaniel Bertalan
We use these to prevent UB from being optimized away in `/bin/crash` and to make the compiler not warn about the many implicit floating point type promotions in LibM.
2021-07-06LibM: Use assembly for all atan versionsHendiadyoin1
2021-07-06LibM: Use fcos for cosineHendiadyoin1
For some reason we were using sin(x+M_PI_2) instead
2021-07-02LibM: Add long double defines of Math ConstantsHediadyoin1
2021-07-02LibM: Implement path for negative powersHendiadyoin1
2021-06-08LibM: Implement nearbyint, nearbyintl and nearbyintfGunnar Beutner
These are used by the ultima engine for scummvm.
2021-05-23LibM: Fix linking with LibM when compiling Userland without -O2Brian Gianforcaro
While playing with conditionally disabling -O2 optimization when building the Userland subdirectory, I discovered that we can no longer link errors without -O2. This happens as LibM.so doesn't link to anything else, resulting in no stack protector implementation. It appears that optimization somehow avoids this problem? To fix this inject LibC/ssp.cpp as we do with in dynamic loader.
2021-05-21Revert "Userland: static vs non-static constexpr variables"Linus Groh
This reverts commit 800ea8ea969835297dc7e7da345a45b9dc5e751a. Booting the system no longer worked after these changes.
2021-05-21Userland: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-09LibC: Add declarations for various C11 math functionsGunnar Beutner
2021-05-09Toolchain+LibM: Make C++ standard library math functions availableGunnar Beutner
With this fixed we get libstdc++v3's aliases for C99 math functions in the std namespace. Unfortunately for this to work the toolchain needs to be rebuilt. The good news are that this by itself does not require a toolchain rebuild just yet.
2021-04-27LibM: Fix INFITITY to floatJean-Baptiste Boric
POSIX mandates it.
2021-04-27Userland: Move non-standard math constants from math.hJean-Baptiste Boric
2021-04-23LibM: Add more macros; increase precision of existing macrosMatthew Olsson
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-16Everywhere: Add `-Wdouble-promotion` warningNicholas-Baron
This warning informs of float-to-double conversions. The best solution seems to be to do math *either* in 32-bit *or* in 64-bit, and only to cross over when absolutely necessary.
2021-04-15LibM: Use fptan/fpatan instead of approximating atan2/tanAnotherTest
The previous versions were very inaccurate, and sometimes wrong.
2021-03-15LibM: Implement fmin/fmaxMițca Dumitru
2021-03-15LibM: Make the gamma family of functions more accurate and conformantMițca Dumitru
This patch makes tgamma use an approximation that is more accurate with regards to floating point arithmetic, and fixes some issues when tgamma was called with positive integer values. It also makes lgamma set signgam to the correct value, and makes its return value be more inline with what the C standard defines.
2021-03-15LibM: Declare rintl in math.hMițca Dumitru
2021-03-14LibM: Add remainder{f, l}Mițca Dumitru
These just forward their arguments to fmod, but I think that should be fine.
2021-03-14LibM: Define HUGE_VAL{F,L} in terms of compiler builtinsMițca Dumitru
2021-03-14LibM: Define MAXFLOATMițca Dumitru
Looks like a POSIX extension
2021-03-14LibM: Define FLT_EVAL_METHOD, float_t and double_tMițca Dumitru
2021-03-14LibM: Declare ldexpl in math.hMițca Dumitru
It was already defined, but it wasn't declared in the header
2021-03-14LibM: Add the gamma family of functionsMițca Dumitru
2021-03-14LibM: Organise math.h so it is less of a wall of functionsMițca Dumitru
The categories are the same categories used by cppreference on its page for numeric functions.
2021-03-14LibM: Implement the missing parts of the round familyMițca Dumitru
2021-03-14LibM: Add missing float and long double function variantsMițca Dumitru
2021-03-13LibM: Implement tanf() in terms of tan() with castsLinus Groh
Lazy, but it works for now. :^)
2021-03-09LibM: Add nan{f, l}Mițca Dumitru
2021-03-09LibM: Implement more rounding functionsMițca Dumitru
This patch implements the entire rint family, while taking into account the current rounding mode, and implements ceil, round, trunc, and floor for types which they weren't before.
2021-03-09LibM: Implement the frexp familyMițca Dumitru
2021-03-09LibM: Implement copysign for float and long doubleMițca Dumitru
2021-03-09LibM: Add scalbn and associated functionsMițca Dumitru
Also implement ldexp in terms of them, and add ldexpl
2021-03-09LibM: Add ilogb and logbMițca Dumitru
2021-03-09LibM: Specialiase FloatExtractor for long double as wellMițca Dumitru
2021-03-09LibM: Define floating point comparsion macrosMițca Dumitru
2021-03-09LibM: Define `math_errhandling` and associated macrosMițca Dumitru
2021-03-06LibM: optimized (branchless) copysignNick Wanninger
2021-03-05LibM: Add naive implementation of copysign()Andreas Kling
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-05LibM: Implement nextafter() and nexttoward()Andreas Kling
Patch from Anonymous.
2021-02-05LibM: Build and install the LibM testAndreas Kling
This test seems to be full of wrong, but at least now we build it and place it in /usr/Tests/LibM/ so that we can fix it.
2021-02-05LibM: Improve accuracy of rounding related functionsAndreas Kling
Patch from Anonymous.
2021-01-18LibM: Add nextafter() and nexttoward() stubsLinus Groh
Only thing missing for Python to build the _math module! :^)
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling