aboutsummaryrefslogtreecommitdiffstats
path: root/tests/math_test.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Accuracy tests for libmJingwei Zhang2015-02-141-16/+436
| | | | | | | | | | | | | | | This patch adds more tests for math functions to address coverage issue of math functions discussed in: https://android-review.googlesource.com/#/c/49653/ https://android-review.googlesource.com/#/c/94780/ These are data sets used in regression tests for the Intel the math library (libm). They were collected over a long period of testing various libm implementations. The data sets contain function specific data (special and corner cases such as +/-0, maximum/minimum normalized numbers, +/-infinity, QNaN/SNaN, maximum/minimum denormal numbers, arguments that would produce close to overflow/underflow results, known hard-to-round cases, etc), implementation specific data (arguments close to table look-up values for different polynomial approximations, worst cases for range reduction algorithms) and other data with interesting bit patterns. The reference values are computed with Maple and were converted into hexadecimal format. Change-Id: I7177c282937369eae98f25d02134e4fc3beadde8 Signed-off-by: Jingwei Zhang <jingwei.zhang@intel.com> Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
* Improve math tests to allow a specific ulp bound.Elliott Hughes2014-11-041-30/+92
| | | | | | | | | | | At the moment our libm is only good enough for a 1 ulp bound on these tests, but that's better than the 4 ulp bound you get from gtest by default. I'm not really happy with the multiple structures and corresponding functions, but at least they mean there's no duplication in the tests themselves, and it should be easy enough for us to make further improvements in future. Change-Id: I004e12970332e1d9531721361d6c34f908cfcecc
* Fix lgamma_r/lgammaf_r/lgammal_r for -0.Elliott Hughes2014-09-181-0/+39
| | | | | | | | Upstream has implemented lgammal/lgammal_r for ld128, and fixed the sign problem we reported with all the lgamma*_r functions and -0. Bug: 17471883 Change-Id: Ibb175d9cab67efae75f1010796fd44c9ba6ce4fc
* The nextafter functions use the wrong next representable valueJingwei Zhang2014-09-191-9/+9
| | | | | | | | | | | | | From C99 standard: “The nextafter functions determine the next representable value, in the type of the function, after x in the direction of y, where x and y are first converted to the type of the function”. The next representable value of 0.0 in direction of -1.0 is -4.9406564584124654e-324, not 0.0. Similar thing holds for nextafterf, nextafterl, nexttowardf, nexttoward, and nexttowardl. The tests pass either way, since the error is within the tolerance, but how it is written is wrong. Change-Id: I1338eeffe3de8031a48f46e1b07146bc07dc2f0a Signed-off-by: Jingwei Zhang <jingwei.zhang@intel.com> Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
* Refactoring: C++11 style DISABLE_ bionic marcosDmitriy Ivanov2014-09-081-11/+11
| | | | | | | | | Enable the -std=gnu++11 flag for libstdc++ static and dynamic libs. ScopeGuard uses DISABLE_ macros instead of '= delete'; Change-Id: I07e21b306f95fffd49345f7fa136cfdac61e0225
* Reset enviroment for math_testsDmitriy Ivanov2014-09-041-0/+37
| | | | | Bug: 17390824 Change-Id: I42f4c8d9199a2efe7641f0b0e64580cacb5695da
* Add a regression test for two libm bugs we didn't have.Elliott Hughes2014-06-061-0/+15
| | | | | | | Reported on the OpenBSD list, but we already had the fix for one from FreeBSD, and I think the other only affected ld80 anyway. Worth having tests thuogh. Change-Id: Ic4bbeb2384fd578a3ef13e4907be83deda50815f
* Use -fvisibility=hidden to build libm.Elliott Hughes2014-05-191-2/+0
| | | | | Bug: 11156955 Change-Id: I77b7772a44313a1eb3970f5d2c8e2af63690efa4
* Fix <math.h> to quieten most of our warnings.Elliott Hughes2014-05-051-2/+0
| | | | | | | | | | | | | | | | | I've reported the wcsftime bug upstream, but we really just want to use -D to ensure the buggy code isn't built. (I've also brought our strftime a bit closer to upstream now we have the right define.) I don't think upstream is likely to fix all their sign-compare and uninitialized warnings, so let's just silence them. As for libm, again upstream isn't likely to fix all their warnings, and silencing those made the ones that were our fault stand out. I've fixed our <math.h> to fix the warnings caused by our lack of definitions for the non-imprecise long-double functions. I checked the C99 standard, and all these functions are there. Change-Id: Iee8e1182c1db375058fb2c451eceb212bab47a37
* Clean-up _fpmath and fake_long_doublesCalin Juravle2014-04-231-3/+20
| | | | | | | | | | | | | | - promoted IEEEld2bits to fpmath since most of the where the same for diffrent archs - removed _fpmath - reinstated weak_references - moved isfinite and isnormal to libc - clean up fake_long_doubles - clean up some useless ifdefs - added missing nexttoward* tests Bug: 14134235 Change-Id: I95639c4885653fe47fd7dc0570ee5bb3389bbc6b
* Reimplement isinf/isnan/fpclassify.Elliott Hughes2014-04-141-0/+12
| | | | | | | | | | | | | | | | Also move isinf and isnan into libc like everyone else. Also move fpclassify to libc like the BSDs (but unlike glibc). We need this to be able to upgrade our float/double/long double parsing to gdtoa. Also add some missing aliases. We now have all of: isnan, __isnan, isnanf, __isnanf, isnanl, __isnanl, isinf, __isinf, isinff, __isinff, isinfl, __isinfl, __fpclassify, __fpclassifyd, __fpclassifyf, __fpclassifyl. Bug: 13469877 Change-Id: I407ffbac06c765a6c5fffda8106c37d7db04f27d
* Fix modf* testsCalin Juravle2014-04-021-20/+7
| | | | | | Use a value that can be exactly represented. Change-Id: Idf3b1db5e6042fb49c1f591f25f9eee656659ece
* Changed long double literal suffix from 'l' to 'L'.Calin Juravle2014-04-011-112/+112
| | | | Change-Id: Id569f2d335b0930704d12ad7f388cb98b65f3ab7
* Fix math tests.Calin Juravle2014-03-281-1/+14
| | | | | Bug: 13657654 Change-Id: I39b2f13b5b3d3e6897618ac3aed49a0a08458dd0
* Add include of float.h for LDBL_MIN_EXP and LDBL_MANT_DIGBrian Carlstrom2014-03-241-0/+1
| | | | | | (cherry picked from commit 1711c6ea3a0d891da665325c75738a68bd7d501f) Change-Id: Ia64676b2b904f042fec678003e3f2cd5bd82b510
* Fix LP64 libm for 128-bit long doublesCalin Juravle2014-03-241-196/+234
| | | | | | | | | | | | | * reworked amd64/_fpmath.h and arm64/_fpmath.h to support 128-bit long doubles. * improved tests to cover long double cases * made modfl an alias for LP32 Tests pass on x86, x86_64, arm, arm64 and mips. Bug: 12921273 Change-Id: Ibe39acde57972447a8950fa45b1e702acc68ebeb
* Fix signbit / infinite / isinf / isnan unit tests.Narayan Kamath2014-02-191-24/+50
| | | | | | | | | | | | | | | | | | | Turns out stlport isn't broken. <cmath> (included transitively via gtest in our case) is not required to make C99 math macros (like signbit) available, nor is it required to preserve them if they're already defined. It is only required to make the equivalent functions in namespace std available. I couldn't find any documentation of required behaviour for programs that include both <math.h> and <cmath>. I've verified experimentally that llvm's libc++ and gnu stl behave the same as stlport. bug: 12935307 Change-Id: I9dc5cc0fd9f4f259abc8eefb280177cdd092a94b
* Make sure that the same tests are on all platforms.Christopher Ferris2014-02-061-22/+44
| | | | | | | | | | | | | | | | In order to be able to generate a list of tests for cts, the same set of tests must exist across all platforms. This CL adds empty tests where a test was conditionally compiled out. This CL creates a single library libBionicTests that includes all of the tests found in bionic-unit-tests-static. Also fix a few missing include files in some test files. Tested by running and compiling the tests for every platform and verifying the same number of tests are on each platform. Change-Id: I9989d4bfebb0f9c409a0ce7e87169299eac605a2
* Add test case for 1^NaNNarayan Kamath2013-11-181-0/+3
| | | | | | Should be 1. Change-Id: I6cf723a419f51d3bda58286a538774b71276c7b5
* Add unit tests for pow's behavior with NaNs.Elliott Hughes2013-11-131-0/+6
| | | | | Bug: 11669804 Change-Id: Idfa6527640c8d0c2cf3e5343bf7afe013e237545
* Put the right number of Ls after 64-bit constants.Elliott Hughes2013-02-121-1/+1
| | | | Change-Id: I9f96259f21e42a84b9ebe20655fe0edb31f41892
* Upgrade libm.Elliott Hughes2013-02-011-0/+1176
This brings us up to date with FreeBSD HEAD, fixes various bugs, unifies the set of functions we support on ARM, MIPS, and x86, fixes "long double", adds ISO C99 support, and adds basic unit tests. It turns out that our "long double" functions have always been broken for non-normal numbers. This patch fixes that by not using the upstream implementations and just forwarding to the regular "double" implementation instead (since "long double" on Android is just "double" anyway, which is what BSD doesn't support). All the tests pass on ARM, MIPS, and x86, plus glibc on x86-64. Bug: 3169850 Bug: 8012787 Bug: https://code.google.com/p/android/issues/detail?id=6697 Change-Id: If0c343030959c24bfc50d4d21c9530052c581837