[commit: ghc] master: base: Update acosh to handle -1::Complex (6458b8d)
git at git.haskell.org
git at git.haskell.org
Tue Sep 5 11:22:14 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/6458b8dcbd33b3c32f3c23f7e5b08fdc6e73ed46/ghc
>---------------------------------------------------------------
commit 6458b8dcbd33b3c32f3c23f7e5b08fdc6e73ed46
Author: Alex Bradley <a.s.bradley1996 at gmail.com>
Date: Mon Sep 4 08:08:46 2017 -0400
base: Update acosh to handle -1::Complex
Summary: Fixes #8532
Reviewers: austin, hvr, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie
GHC Trac Issues: #8532
Differential Revision: https://phabricator.haskell.org/D3916
>---------------------------------------------------------------
6458b8dcbd33b3c32f3c23f7e5b08fdc6e73ed46
libraries/base/Data/Complex.hs | 3 ++-
testsuite/tests/numeric/should_run/all.T | 1 +
testsuite/tests/numeric/should_run/numrun016.hs | 8 ++++++++
testsuite/tests/numeric/should_run/numrun016.stdout | 2 ++
4 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs
index dd3e0ec..e4ed4e8 100644
--- a/libraries/base/Data/Complex.hs
+++ b/libraries/base/Data/Complex.hs
@@ -197,7 +197,8 @@ instance (RealFloat a) => Floating (Complex a) where
where (x':+y') = log (((1-y):+x) / sqrt (1+z*z))
asinh z = log (z + sqrt (1+z*z))
- acosh z = log (z + (z+1) * sqrt ((z-1)/(z+1)))
+ -- Take care to allow (-1)::Complex, fixing #8532
+ acosh z = log (z + (sqrt $ z+1) * (sqrt $ z-1))
atanh z = 0.5 * log ((1.0+z) / (1.0-z))
log1p x@(a :+ b)
diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T
index 2d2353b..fd9c05f 100644
--- a/testsuite/tests/numeric/should_run/all.T
+++ b/testsuite/tests/numeric/should_run/all.T
@@ -34,6 +34,7 @@ test('numrun012', normal, compile_and_run, [''])
test('numrun013', normal, compile_and_run, [''])
test('numrun014', normal, compile_and_run, [''])
test('numrun015', normal, compile_and_run, [''])
+test('numrun016', normal, compile_and_run, [''])
test('arith016', normal, compile_and_run, [''])
test('arith017', normal, compile_and_run, [''])
test('arith018', normal, compile_and_run, [''])
diff --git a/testsuite/tests/numeric/should_run/numrun016.hs b/testsuite/tests/numeric/should_run/numrun016.hs
new file mode 100644
index 0000000..c45e322
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/numrun016.hs
@@ -0,0 +1,8 @@
+-- test for trac #8532
+
+import Data.Complex
+
+main :: IO ()
+main = do
+ print $ acosh ((-1)::Complex Double)
+ print $ acosh ((-1)::Complex Float)
diff --git a/testsuite/tests/numeric/should_run/numrun016.stdout b/testsuite/tests/numeric/should_run/numrun016.stdout
new file mode 100644
index 0000000..25676f7
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/numrun016.stdout
@@ -0,0 +1,2 @@
+0.0 :+ 3.141592653589793
+0.0 :+ 3.1415927
\ No newline at end of file
More information about the ghc-commits
mailing list