The Complex structure


Synopsis

signature COMPLEX
structure Complex : COMPLEX
The Complex structure implements floating-point complex numbers. It is implemented as a composition of two REAL numbers for the real and imaginary parts of the number.

Interface

type complex

val i : complex

val fromReal : real -> complex
val fromInt : int -> complex

val magnitude : complex -> real
val phase : complex -> real

val fromPolar : {magnitude:real,phase:real} -> complex

val toString : complex -> string

val ~ : complex -> complex

val conj : complex -> complex
val ~~ : complex -> complex

val + : complex * complex -> complex
val - : complex * complex -> complex
val * : complex * complex -> complex
val / : complex * complex -> complex

val exp : complex -> complex
val ln : complex -> complex

val pow : complex * complex -> complex

val sin : complex -> complex
val cos : complex -> complex

Details

type complex = {real:real,imag:real}
As complex is implemented as the composition of the real and imaginary parts of the complex number, it is not an equality type.

val i : complex
The square root of ~1.0

val fromReal : real -> complex
Converts from an real to complex.

val fromInt : int -> complex
Converts from an integer to complex.

val magnitude : complex -> real
Returns the magnitude of the complex number.

val phase : complex -> real
Returns the phase of the complex number, in the range (~Math.pi,Math.pi)

val fromPolar : {magnitude:real,phase:real} -> complex
Converts from magnitude and phase to complex.

val toString : complex -> string
Converts to a string of the form "0.0+1.0i", using Real.toString concatenated with "+" and appended with "i".

val ~ : complex -> complex
Negates the argument (both real and imaginary parts).

val conj : complex -> complex
val ~~ : complex -> complex
Returns the complex conjugate of the argument. That is, the real part is unchanged, and the sign bit is flipped on the imaginary part.

val + : complex * complex -> complex
Sum the two arguments.

val - : complex * complex -> complex
Subtract the second argument from the first.

val * : complex * complex -> complex
Multiply the two arguments.

val / : complex * complex -> complex
Divide the first argument by the second.

val exp : complex -> complex
Returns en where n is the argument.

val ln : complex -> complex
Returns the natural logarithm of the argument.

val pow : complex * complex -> complex
Returns the first argument raised to the second argument power.

val sin : complex -> complex
Return the sine of the argument.

val cos : complex -> complex
Return the cosine of the argument.


Last modified: Sat Dec 17 16:01:30 Mountain Standard Time 2005
rlpm [ -at- ] cs.unm.edu