Luftzig / elm-signal-processing / Complex

Simple module for handling complex numbers. This module was made for the needs of the signal processing library and thus kept to minimum.

Types


type alias Complex =
{ re : Basics.Float, im : Basics.Float }

Simple representation of a complex number

Constructors

imaginary : Basics.Float -> Complex

Construct a Complex number with imaginary value only

imaginary 1 --> { re = 0, im = 1 }

real : Basics.Float -> Complex

Construct a Complex number with real value only

real 1 --> { re = 1, im = 0 }

zero : Complex

The complex zero

Binary Operators

add : Complex -> Complex -> Complex

Add two complex numbers

add (real 1) (imaginary 2) --> { re = 1, im = 2 }

subtract : Complex -> Complex -> Complex

Subtract two complex numbers

subtract { re = 1, im = 2 } (real 2) --> { re = -1, im = 2 }

multiply : Complex -> Complex -> Complex

Multiply two complex numbers

multiply (imaginary 1) (real 2) --> { re = 0, im = 2 }

divideByReal : Basics.Float -> Complex -> Complex

Divide a complex number by a real number. Notice that the divisor is given first.

real 2 |> divideByReal 2 --> { re = 1, im = 0 }

equal : Complex -> Complex -> Basics.Bool

Check equality of two complex numbers

Unary Operators

exp : Complex -> Complex

Given complex number z, computes e^z

abs : Complex -> Basics.Float

The absolute value of complex number, which is also its distance from zero

conjugate : Complex -> Complex

computes the conjugate of a complex number

conjugate { re = 1, im = 1 } --> { re = 1, im = -1 }