diff options
author | Ian Lynagh <igloo@earth.li> | 2008-10-04 14:26:51 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2008-10-04 14:26:51 +0000 |
commit | 4ae7c074eca24ac54e33ab9a83d0272460c19994 (patch) | |
tree | 63dfeb634e05341d2254f4163f3e2f1b95e672b6 /libraries/base/Data/Complex.hs | |
parent | e92129766b790f47aac45ab561d38092a2ed42b7 (diff) | |
download | haskell-4ae7c074eca24ac54e33ab9a83d0272460c19994.tar.gz |
Don't use ^(2::Int) in Data.Complex.magnitude; partially fixes trac #2450
We still might want to make a RULE for this, so the bug is not fully fixed.
Diffstat (limited to 'libraries/base/Data/Complex.hs')
-rw-r--r-- | libraries/base/Data/Complex.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs index 3acfa0382f..60ee83469c 100644 --- a/libraries/base/Data/Complex.hs +++ b/libraries/base/Data/Complex.hs @@ -103,9 +103,10 @@ polar z = (magnitude z, phase z) {-# 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 + 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. |