From d6adf6bd595c3b8f750acc9293f5847f176b521b Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sat, 4 Oct 2008 14:26:51 +0000 Subject: [PATCH] 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. --- Data/Complex.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Data/Complex.hs b/Data/Complex.hs index 3acfa03..60ee834 100644 --- a/Data/Complex.hs +++ b/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. -- 1.7.10.4