projects
/
ghc-base.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update source repo location to be the git repo in .cabal file
[ghc-base.git]
/
Data
/
Complex.hs
diff --git
a/Data/Complex.hs
b/Data/Complex.hs
index
7d29e77
..
9765eda
100644
(file)
--- a/
Data/Complex.hs
+++ b/
Data/Complex.hs
@@
-1,3
+1,5
@@
+{-# LANGUAGE CPP, DeriveDataTypeable #-}
+
-----------------------------------------------------------------------------
-- |
-- Module : Data.Complex
-----------------------------------------------------------------------------
-- |
-- Module : Data.Complex
@@
-45,7
+47,7
@@
import Prelude
import Data.Typeable
#ifdef __GLASGOW_HASKELL__
import Data.Typeable
#ifdef __GLASGOW_HASKELL__
-import Data.Generics.Basics( Data )
+import Data.Data (Data)
#endif
#ifdef __HUGS__
#endif
#ifdef __HUGS__
@@
-110,9
+112,10
@@
polar z = (magnitude z, phase z)
{-# SPECIALISE magnitude :: Complex Double -> Double #-}
magnitude :: (RealFloat a) => Complex a -> a
magnitude (x:+y) = scaleFloat k
{-# SPECIALISE magnitude :: Complex Double -> Double #-}
magnitude :: (RealFloat a) => Complex a -> a
magnitude (x:+y) = scaleFloat k
- (sqrt ((scaleFloat mk x)^(2::Int) + (scaleFloat mk y)^(2::Int)))
+ (sqrt (sqr (scaleFloat mk x) + sqr (scaleFloat mk y)))
where k = max (exponent x) (exponent y)
mk = - k
where k = max (exponent x) (exponent y)
mk = - k
+ sqr z = z * z
-- | The phase of a complex number, in the range @(-'pi', 'pi']@.
-- If the magnitude is zero, then so is the phase.
-- | The phase of a complex number, in the range @(-'pi', 'pi']@.
-- If the magnitude is zero, then so is the phase.
@@
-197,4
+200,4
@@
instance (RealFloat a) => Floating (Complex a) where
asinh z = log (z + sqrt (1+z*z))
acosh z = log (z + (z+1) * sqrt ((z-1)/(z+1)))
asinh z = log (z + sqrt (1+z*z))
acosh z = log (z + (z+1) * sqrt ((z-1)/(z+1)))
- atanh z = log ((1+z) / sqrt (1-z*z))
+ atanh z = 0.5 * log ((1.0+z) / (1.0-z))