shady-gen-0.5.1: Functional GPU programming - DSEL & compiler

Portability portable provisional conal@conal.net

Description

Complex numbers. This version is modified from Data.Complex in base. It eliminates the RealFloat requirement by using a more naive definition of `magnitude`. Also, defines instances for vector-space classes.

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

Instances

 Typeable1 Complex Eq a => Eq (Complex a) Floating a => Floating (Complex a) Floating a => Fractional (Complex a) Data a => Data (Complex a) Floating a => Num (Complex a) Read a => Read (Complex a) Show a => Show (Complex a) Floating a => VectorSpace (Complex a) Floating a => InnerSpace (Complex a) Floating a => AdditiveGroup (Complex a) FMod s => FMod (Complex s) Frac s => Frac (Complex s) HasExpr a => HasExpr (Complex a) (Show a, IsScalar a) => FromE (ComplexE a) (Show a, IsScalar a) => ToE (ComplexE a)

realPart :: Complex a -> aSource

Extracts the real part of a complex number.

imagPart :: Complex a -> aSource

Extracts the imaginary part of a complex number.

# Polar form

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

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

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

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

polar :: Floating 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.

phase :: Floating a => Complex a -> aSource

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 => Unop (Complex a)Source

The conjugate of a complex number.