variable-precision-0.2: variable-precision floating point

Portability DeriveDataTypeable, GeneralizedNewtypeDeriving, Rank2Types unstable claudiusmaximus@goto10.org None

Numeric.VariablePrecision.Complex

Description

Newtype wrapper around `Complex`. When both of `Complex` and this module need to be imported, use qualified imports.

Synopsis

# Documentation

data VComplex p Source

Newtype wrapper around `Complex` so that instances can be written for `HasPrecision` and `VariablePrecision`.

Instances

 Typeable1 VComplex VariablePrecision VComplex HasPrecision VComplex Normed VComplex Eq (VComplex p) NaturalNumber p => Floating (VComplex p) NaturalNumber p => Fractional (VComplex p) Data p => Data (VComplex p) NaturalNumber p => Num (VComplex p) NaturalNumber p => Read (VComplex p) NaturalNumber p => Show (VComplex p)

(.+) :: NaturalNumber p => VFloat p -> VFloat p -> VComplex pSource

Alike to `:+`, constructs a complex number from a real part and an imaginary part.

(.*) :: NaturalNumber p => VFloat p -> VComplex p -> VComplex pSource

Real-complex multiplication.

(*.) :: NaturalNumber p => VComplex p -> VFloat p -> VComplex pSource

Complex-real multiplication.

toComplex :: VComplex p -> Complex (VFloat p)Source

Convert `VComplex` to `Complex`.

Convert `Complex` to `VComplex`.

withComplex :: (Complex (VFloat p) -> Complex (VFloat q)) -> VComplex p -> VComplex qSource

Lift an operation on `Complex` to one on `VComplex`.

mapComplex :: (RealFloat a, RealFloat b) => (a -> b) -> Complex a -> Complex bSource

Apply a function to both components of a complex number.

recodeComplex :: (RealFloat a, RealFloat b) => Complex a -> Complex bSource

Much like `mapComplex` `recodeFloat`.

scaleComplex :: NaturalNumber p => Int -> VComplex p -> VComplex pSource

Much like `withComplex` `scaleComplex'`.

realPart :: NaturalNumber p => VComplex p -> VFloat pSource

Real part.

imagPart :: NaturalNumber p => VComplex p -> VFloat pSource

Imaginary part.

magnitude :: NaturalNumber p => VComplex p -> VFloat pSource

Magnitude.

magnitude2 :: NaturalNumber p => VComplex p -> VFloat pSource

Magnitude squared.

sqr :: NaturalNumber p => VComplex p -> VComplex pSource

Complex square.

polar :: NaturalNumber p => VComplex p -> (VFloat p, VFloat p)Source

Polar form.

cis :: NaturalNumber p => VFloat p -> VComplex pSource

Unit at phase.

mkPolar :: NaturalNumber p => VFloat p -> VFloat p -> VComplex pSource

From polar form.

scaleComplex' :: RealFloat r => Int -> Complex r -> Complex rSource

Much like `mapComplex` `scaleFloat`.

magnitude2' :: RealFloat r => Complex r -> rSource

Magnitude squared.

sqr' :: RealFloat r => Complex r -> Complex rSource

Complex square.

data DComplex Source

A concrete format suitable for storage or wire transmission.

Constructors

 DComplex FieldsdRealPart :: !DFloat dImagPart :: !DFloat

Instances

 Eq DComplex Data DComplex Ord DComplex Read DComplex Show DComplex Typeable DComplex

Freeze a `VComplex`.

Thaw a `DComplex`. Results in `Nothing` on precision mismatch.

withDComplex :: DComplex -> (forall p. NaturalNumber p => Maybe (VComplex p) -> r) -> rSource

Thaw a `DComplex` to its natural precision. `Nothing` is passed on precision mismatch between real and imaginary parts.