## Abstract

Complex numbers parameterised over the representation of their real parts.

Divided into a module type for modules that implement complex numbers, and a parametric module that can construct such modules.

## Synopsis

module type complex = {
 type real type complex type t = complex val mk : real -> real -> complex val mk_re : real -> complex val mk_im : real -> complex val i64 : i64 -> complex val conj : complex -> complex val neg : complex -> complex val re : complex -> real val im : complex -> real val mag : complex -> real val arg : complex -> real val + : complex -> complex -> complex val - : complex -> complex -> complex val * : complex -> complex -> complex val / : complex -> complex -> complex val ** : complex -> complex -> complex val < : complex -> complex -> bool val > : complex -> complex -> bool val >= : complex -> complex -> bool val <= : complex -> complex -> bool val sqrt : complex -> complex val exp : complex -> complex val log : complex -> complex val abs : complex -> complex val fma : complex -> complex -> complex -> complex val sum [n]: [n]complex -> complex
}
module mk_complex: (T: real) -> (complex with real = T.t with complex = (T.t, T.t))

## Description

module type complex

The type of modules that implement a notion of complex numbers. Semantically, a complex number can be seen as a pair of two numbers (but this need not be the representation).

type real

The type of the components of the complex number.

type complex

The type of complex numbers.

type t = complex

Helper type for easy compatiblity with other modules.

val mk: real -> real -> complex

Construct a complex number from real and imaginary components.

val mk_re: real -> complex

Construct a complex number from just the real component. The imaginary part will be zero.

val mk_im: real -> complex

Construct a complex number from just the imaginary component. The real part will be zero.

val i64: i64 -> complex

Construct a complex number from i64. The imaginary part will be zero.

val conj: complex -> complex

Conjugate a complex number.

val neg: complex -> complex

Negate a complex number.

val re: complex -> real

The real part of a complex number.

val im: complex -> real

The imaginary part of a complex number.

val mag: complex -> real

The magnitude (or modulus, or absolute value) of a complex number.

val arg: complex -> real

The argument (or phase) of a complex number.

val +: complex -> complex -> complex
val -: complex -> complex -> complex
val *: complex -> complex -> complex
val /: complex -> complex -> complex
val **: complex -> complex -> complex
val <: complex -> complex -> bool
val >: complex -> complex -> bool
val >=: complex -> complex -> bool
val <=: complex -> complex -> bool
val sqrt: complex -> complex
val exp: complex -> complex
val log: complex -> complex
val abs: complex -> complex
val fma: complex -> complex -> complex -> complex
val sum [n]: [n]complex -> complex
module mk_complex

Given a module describing a number type, construct a module implementing complex numbers.