base-4.8.2.0: Basic libraries

Copyright (c) The University of Glasgow 2001 BSD-style (see the file libraries/base/LICENSE) libraries@haskell.org provisional portable Trustworthy Haskell2010

Data.Complex

Description

Complex numbers.

Synopsis

# Rectangular form

data Complex a Source

Complex numbers are an algebraic type.

For a complex number `z`, `abs z` is a number with the magnitude of `z`, but oriented in the positive real direction, whereas `signum z` has the phase of `z`, but unit magnitude.

Constructors

 !a :+ !a infix 6 forms a complex number from its real and imaginary rectangular components.

Instances

 Eq a => Eq (Complex a) Source Methods(==) :: Complex a -> Complex a -> Bool(/=) :: Complex a -> Complex a -> Bool RealFloat a => Floating (Complex a) Source Methodsexp :: Complex a -> Complex a Sourcelog :: Complex a -> Complex a Sourcesqrt :: Complex a -> Complex a Source(**) :: Complex a -> Complex a -> Complex a SourcelogBase :: Complex a -> Complex a -> Complex a Sourcesin :: Complex a -> Complex a Sourcecos :: Complex a -> Complex a Sourcetan :: Complex a -> Complex a Sourceasin :: Complex a -> Complex a Sourceacos :: Complex a -> Complex a Sourceatan :: Complex a -> Complex a Sourcesinh :: Complex a -> Complex a Sourcecosh :: Complex a -> Complex a Sourcetanh :: Complex a -> Complex a Sourceasinh :: Complex a -> Complex a Sourceacosh :: Complex a -> Complex a Sourceatanh :: Complex a -> Complex a Source RealFloat a => Fractional (Complex a) Source Methods(/) :: Complex a -> Complex a -> Complex a Sourcerecip :: Complex a -> Complex a Source Data a => Data (Complex a) Source Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Complex a -> c (Complex a) Sourcegunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Complex a) SourcedataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Complex a)) SourcedataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Complex a)) SourcegmapT :: (forall b. Data b => b -> b) -> Complex a -> Complex a SourcegmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Complex a -> r SourcegmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Complex a -> r SourcegmapQ :: (forall d. Data d => d -> u) -> Complex a -> [u] SourcegmapQi :: Int -> (forall d. Data d => d -> u) -> Complex a -> u SourcegmapM :: Monad m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) SourcegmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) SourcegmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) Source RealFloat a => Num (Complex a) Source Methods(+) :: Complex a -> Complex a -> Complex a Source(-) :: Complex a -> Complex a -> Complex a Source(*) :: Complex a -> Complex a -> Complex a Sourcenegate :: Complex a -> Complex a Sourceabs :: Complex a -> Complex a Sourcesignum :: Complex a -> Complex a Source Read a => Read (Complex a) Source Methods Show a => Show (Complex a) Source MethodsshowsPrec :: Int -> Complex a -> ShowS Sourceshow :: Complex a -> String SourceshowList :: [Complex a] -> ShowS Source Storable a => Storable (Complex a) Source MethodssizeOf :: Complex a -> Int SourcepeekElemOff :: Ptr (Complex a) -> Int -> IO (Complex a) SourcepokeElemOff :: Ptr (Complex a) -> Int -> Complex a -> IO () SourcepeekByteOff :: Ptr b -> Int -> IO (Complex a) SourcepokeByteOff :: Ptr b -> Int -> Complex a -> IO () Sourcepeek :: Ptr (Complex a) -> IO (Complex a) Sourcepoke :: Ptr (Complex a) -> Complex a -> IO () Source

realPart :: Complex a -> a Source

Extracts the real part of a complex number.

imagPart :: Complex a -> a Source

Extracts the imaginary part of a complex number.

# Polar form

mkPolar :: Floating a => a -> a -> Complex a Source

Form a complex number from polar components of magnitude and phase.

cis :: Floating a => a -> Complex a Source

`cis t` is a complex value with magnitude `1` and phase `t` (modulo `2*pi`).

polar :: RealFloat a => Complex a -> (a, a) Source

The function `polar` takes a complex number and returns a (magnitude, phase) pair in canonical form: the magnitude is nonnegative, and the phase in the range `(-pi, pi]`; if the magnitude is zero, then so is the phase.

magnitude :: RealFloat a => Complex a -> a Source

The nonnegative magnitude of a complex number.

phase :: RealFloat a => Complex a -> a Source

The phase of a complex number, in the range `(-pi, pi]`. If the magnitude is zero, then so is the phase.

# Conjugate

conjugate :: Num a => Complex a -> Complex a Source

The conjugate of a complex number.