| base-4.1.0.0: Basic libraries | Source code | Contents | Index

Data.Complex

Portability | portable
Stability | provisional
Maintainer | libraries@haskell.org

Contents

Rectangular form
Polar form
Conjugate

Description
Complex numbers.
Synopsis

data RealFloat a => Complex a = !a :+ !a
realPart :: RealFloat a => Complex a -> a
imagPart :: RealFloat a => Complex a -> a
mkPolar :: RealFloat a => a -> a -> Complex a
cis :: RealFloat a => a -> Complex a
polar :: RealFloat a => Complex a -> (a, a)
magnitude :: RealFloat a => Complex a -> a
phase :: RealFloat a => Complex a -> a
conjugate :: RealFloat a => Complex a -> Complex a

Rectangular form

data RealFloat a => 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 | forms a complex number from its real and imaginary rectangular components.

Instances

Typeable1 Complex
RealFloat a => Eq (Complex a)
RealFloat a => Floating (Complex a)
RealFloat a => Fractional (Complex a)
(Data a, RealFloat a) => Data (Complex a)
RealFloat a => Num (Complex a)
(Read a, RealFloat a) => Read (Complex a)
RealFloat a => Show (Complex a)

realPart :: RealFloat a => Complex a -> a | Source

Extracts the real part of a complex number.

imagPart :: RealFloat a => Complex a -> a | Source

Extracts the imaginary part of a complex number.
Polar form

mkPolar :: RealFloat a => a -> a -> Complex a | Source

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

cis :: RealFloat 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 :: RealFloat a => Complex a -> Complex a | Source

The conjugate of a complex number.
Produced by Haddock version 2.4.2