summaryrefslogtreecommitdiff
path: root/libraries/base/Data/Complex.hs
diff options
context:
space:
mode:
authorKavon Farvardin <kavon@farvard.in>2018-09-23 15:29:37 -0500
committerKavon Farvardin <kavon@farvard.in>2018-09-23 15:29:37 -0500
commit84c2ad99582391005b5e873198b15e9e9eb4f78d (patch)
treecaa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /libraries/base/Data/Complex.hs
parent8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff)
parente68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff)
downloadhaskell-wip/T13904.tar.gz
update to current master againwip/T13904
Diffstat (limited to 'libraries/base/Data/Complex.hs')
-rw-r--r--libraries/base/Data/Complex.hs19
1 files changed, 16 insertions, 3 deletions
diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs
index dd3e0eca0b..a544a5bf6c 100644
--- a/libraries/base/Data/Complex.hs
+++ b/libraries/base/Data/Complex.hs
@@ -55,11 +55,23 @@ infix 6 :+
-- has the phase of @z@, but unit magnitude.
--
-- The 'Foldable' and 'Traversable' instances traverse the real part first.
+--
+-- Note that `Complex`'s instances inherit the deficiencies from the type
+-- parameter's. For example, @Complex Float@'s 'Ord' instance has similar
+-- problems to `Float`'s.
data Complex a
= !a :+ !a -- ^ forms a complex number from its real and imaginary
-- rectangular components.
- deriving (Eq, Show, Read, Data, Generic, Generic1
- , Functor, Foldable, Traversable)
+ deriving ( Eq -- ^ @since 2.01
+ , Show -- ^ @since 2.01
+ , Read -- ^ @since 2.01
+ , Data -- ^ @since 2.01
+ , Generic -- ^ @since 4.9.0.0
+ , Generic1 -- ^ @since 4.9.0.0
+ , Functor -- ^ @since 4.9.0.0
+ , Foldable -- ^ @since 4.9.0.0
+ , Traversable -- ^ @since 4.9.0.0
+ )
-- -----------------------------------------------------------------------------
-- Functions over Complex
@@ -197,7 +209,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)