Owl_base_complex
val zero : t
Constant value representing the complex number zero (0 + 0i).
val one : t
Constant value representing the complex number one (1 + 0i).
val i : t
Constant value representing the imaginary unit i (0 + 1i).
neg z
returns the negation of the complex number z
. If z = a + bi
, then neg z = -a - bi
.
val abs : t -> float
abs z
returns the magnitude (absolute value) of the complex number z
. This is computed as sqrt(Re(z)^2 + Im(z)^2).
val abs2 : t -> float
abs2 z
returns the squared magnitude of the complex number z
. This is computed as Re(z)^2 + Im(z)^2.
val logabs : t -> float
logabs z
returns the natural logarithm of the magnitude of the complex number z
.
conj z
returns the complex conjugate of the complex number z
. If z = a + bi
, then conj z = a - bi
.
inv z
returns the multiplicative inverse of the complex number z
. This is computed as 1 / z.
exp10 z
returns 10 raised to the power of the complex number z
, calculated as 10^z.
expm1 z
returns the value of exp(z) - 1, providing a more accurate result for small values of z
.
log1p z
returns the natural logarithm of (1 + z), providing a more accurate result for small values of z
.
val arg : t -> float
arg x
returns the angle of a complex number x
.
val phase : t -> float
phase x
returns the phase of a complex number x
.
add_re z r
adds the real number r
to the real part of the complex number z
. Returns a new complex number with the real part increased by r
.
add_im z i
adds the real number i
to the imaginary part of the complex number z
. Returns a new complex number with the imaginary part increased by i
.
sub_re z r
subtracts the real number r
from the real part of the complex number z
. Returns a new complex number with the real part decreased by r
.
sub_im z i
subtracts the real number i
from the imaginary part of the complex number z
. Returns a new complex number with the imaginary part decreased by i
.
mul_re z r
multiplies the real part of the complex number z
by the real number r
. Returns a new complex number with the real part scaled by r
.
mul_im z i
multiplies the imaginary part of the complex number z
by the real number i
. Returns a new complex number with the imaginary part scaled by i
.
div_re z r
divides the real part of the complex number z
by the real number r
. Returns a new complex number with the real part divided by r
.
div_im z i
divides the imaginary part of the complex number z
by the real number i
. Returns a new complex number with the imaginary part divided by i
.
pow z1 z2
raises the complex number z1
to the power of z2
. Returns a new complex number representing z1
raised to z2
.
val polar : float -> float -> t
polar r theta
creates a complex number from the polar coordinates r
(magnitude) and theta
(angle in radians). Returns a new complex number.
val rect : float -> float -> t
rect r phi
returns a complex number with polar coordinates r
and phi
. Equivalent to polar r phi
.
equal z1 z2
returns true
if the complex numbers z1
and z2
are equal, false
otherwise.
not_equal z1 z2
returns true
if the complex numbers z1
and z2
are not equal, false
otherwise.
less z1 z2
returns true
if the magnitude of the complex number z1
is less than that of z2
.
greater z1 z2
returns true
if the magnitude of the complex number z1
is greater than that of z2
.
less_equal z1 z2
returns true
if the magnitude of the complex number z1
is less than or equal to that of z2
.
greater_equal z1 z2
returns true
if the magnitude of the complex number z1
is greater than or equal to that of z2
.
val complex : float -> float -> t
complex re im
returns a complex number {re; im}
.
val of_tuple : (float * float) -> t
of_tuple (re, im)
returns a complex number {re; im}
.
val to_tuple : t -> float * float
to_tuple x
converts a complex number to tuple (x.re; x.im)
.
val is_nan : t -> bool
is_nan x
returns true
if x.re
is nan
or x.im
is nan
.
val is_inf : t -> bool
is_inf x
returns true
if either x.re
or x.im
is infinity
or neg_infinity
.
val is_normal : t -> bool
is_normal x
returns true
if both x.re
and x.im
are normal
.