X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FComplex.hs;h=3b37f6c91f0b8dea033afffd3ce03c7d38e5ad3f;hb=6b1a36a595eddf1e124529646afdb75c76a9966d;hp=263b0526201c415b749629603b557db8a47fedee;hpb=d1d83f8663afa876603cd42c7f5e20478ad44567;p=haskell-directory.git diff --git a/Data/Complex.hs b/Data/Complex.hs index 263b052..3b37f6c 100644 --- a/Data/Complex.hs +++ b/Data/Complex.hs @@ -44,7 +44,9 @@ module Data.Complex import Prelude import Data.Typeable +#ifdef __GLASGOW_HASKELL__ import Data.Generics.Basics( Data ) +#endif #ifdef __HUGS__ import Hugs.Prelude(Num(fromInt), Fractional(fromDouble)) @@ -134,7 +136,7 @@ instance (RealFloat a) => Num (Complex a) where (x:+y) * (x':+y') = (x*x'-y*y') :+ (x*y'+y*x') negate (x:+y) = negate x :+ negate y abs z = magnitude z :+ 0 - signum 0 = 0 + signum (0:+0) = 0 signum z@(x:+y) = x/r :+ y/r where r = magnitude z fromInteger n = fromInteger n :+ 0 #ifdef __HUGS__ @@ -163,7 +165,7 @@ instance (RealFloat a) => Floating (Complex a) where where expx = exp x log z = log (magnitude z) :+ phase z - sqrt 0 = 0 + sqrt (0:+0) = 0 sqrt z@(x:+y) = u :+ (if y < 0 then -v else v) where (u,v) = if x < 0 then (v',u') else (u',v') v' = abs y / (u'*2)