diff options
Diffstat (limited to 'libraries/base/Data/Complex.hs')
-rw-r--r-- | libraries/base/Data/Complex.hs | 19 |
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) |