projects
/
haskell-directory.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add System.Posix.Types to default nhc98 build
[haskell-directory.git]
/
Data
/
Complex.hs
diff --git
a/Data/Complex.hs
b/Data/Complex.hs
index
6a76279
..
3b37f6c
100644
(file)
--- a/
Data/Complex.hs
+++ b/
Data/Complex.hs
@@
-44,7
+44,7
@@
module Data.Complex
import Prelude
import Data.Typeable
import Prelude
import Data.Typeable
-#ifndef __NHC__
+#ifdef __GLASGOW_HASKELL__
import Data.Generics.Basics( Data )
#endif
import Data.Generics.Basics( Data )
#endif
@@
-136,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
(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__
signum z@(x:+y) = x/r :+ y/r where r = magnitude z
fromInteger n = fromInteger n :+ 0
#ifdef __HUGS__
@@
-165,7
+165,7
@@
instance (RealFloat a) => Floating (Complex a) where
where expx = exp x
log z = log (magnitude z) :+ phase z
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)
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)