summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/numerics
diff options
context:
space:
mode:
authorMikhail Maltsev <mikhail.maltsev@arm.com>2018-02-19 15:41:36 +0000
committerMikhail Maltsev <mikhail.maltsev@arm.com>2018-02-19 15:41:36 +0000
commit477b5f688c80064753827693c16d49957d3a3a95 (patch)
tree19c3ec8c8ef9a89cfa83273a5476ee1a3b62c8da /libcxx/test/std/numerics
parent9b2aa42f00253d5a5fd8153bfb28481a62beb8d9 (diff)
downloadbcm5719-llvm-477b5f688c80064753827693c16d49957d3a3a95.tar.gz
bcm5719-llvm-477b5f688c80064753827693c16d49957d3a3a95.zip
[libcxx] Improve accuracy of complex asinh and acosh
Summary: Currently std::asinh and std::acosh use std::pow to compute x^2. This results in a significant error when computing e.g. asinh(i) or acosh(-1). This patch expresses x^2 directly via x.real() and x.imag(), like it is done in libstdc++/glibc, and adds tests that checks the accuracy. Reviewers: EricWF, mclow.lists Reviewed By: mclow.lists Subscribers: christof, cfe-commits Differential Revision: https://reviews.llvm.org/D41629 llvm-svn: 325510
Diffstat (limited to 'libcxx/test/std/numerics')
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp9
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp9
2 files changed, 18 insertions, 0 deletions
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
index deb056d67de..5258bdc3a0f 100644
--- a/libcxx/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
@@ -54,6 +54,15 @@ void test_edges()
assert(r.imag() == 0);
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
}
+ else if (testcases[i].real() == -1 && testcases[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ assert(!std::signbit(r.real()));
+ if (std::signbit(testcases[i].imag()))
+ is_about(r.imag(), -pi);
+ else
+ is_about(r.imag(), pi);
+ }
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
{
assert(std::isinf(r.real()));
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
index 3da56c32f19..cb9188d935a 100644
--- a/libcxx/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
@@ -44,6 +44,15 @@ void test_edges()
assert(std::signbit(r.real()) == std::signbit(testcases[i].real()));
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
}
+ else if (testcases[i].real() == 0 && std::abs(testcases[i].imag()) == 1)
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
+ if (std::signbit(testcases[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
{
assert(std::isinf(r.real()));
OpenPOWER on IntegriCloud