[project @ 2002-05-09 13:16:29 by simonmar]
[ghc-base.git] / Data / Complex.hs
index e132f21..8ad4c2e 100644 (file)
@@ -1,15 +1,13 @@
 -----------------------------------------------------------------------------
--- 
+-- |
 -- Module      :  Data.Complex
 -- Copyright   :  (c) The University of Glasgow 2001
--- License     :  BSD-style (see the file libraries/core/LICENSE)
+-- License     :  BSD-style (see the file libraries/base/LICENSE)
 -- 
 -- Maintainer  :  libraries@haskell.org
 -- Stability   :  provisional
 -- Portability :  portable
 --
--- $Id: Complex.hs,v 1.1 2001/06/28 14:15:02 simonmar Exp $
---
 -- Complex numbers.
 --
 -----------------------------------------------------------------------------
@@ -58,24 +56,30 @@ realPart, imagPart :: (RealFloat a) => Complex a -> a
 realPart (x :+ _) =  x
 imagPart (_ :+ y) =  y
 
+{-# SPECIALISE conjugate :: Complex Double -> Complex Double #-}
 conjugate       :: (RealFloat a) => Complex a -> Complex a
 conjugate (x:+y) =  x :+ (-y)
 
+{-# SPECIALISE mkPolar :: Double -> Double -> Complex Double #-}
 mkPolar                 :: (RealFloat a) => a -> a -> Complex a
 mkPolar r theta         =  r * cos theta :+ r * sin theta
 
+{-# SPECIALISE cis :: Double -> Complex Double #-}
 cis             :: (RealFloat a) => a -> Complex a
 cis theta       =  cos theta :+ sin theta
 
+{-# SPECIALISE polar :: Complex Double -> (Double,Double) #-}
 polar           :: (RealFloat a) => Complex a -> (a,a)
 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)))
                    where k  = max (exponent x) (exponent y)
                          mk = - k
 
+{-# SPECIALISE phase :: Complex Double -> Double #-}
 phase :: (RealFloat a) => Complex a -> a
 phase (0 :+ 0)   = 0           -- SLPJ July 97 from John Peterson
 phase (x:+y)    = atan2 y x