octave: Complex Arithmetic
17.2 Complex Arithmetic
=======================
In the descriptions of the following functions, Z is the complex number
X + IY, where I is defined as ‘sqrt (-1)’.
-- : abs (Z)
Compute the magnitude of Z.
The magnitude is defined as |Z| = ‘sqrt (x^2 + y^2)’.
For example:
abs (3 + 4i)
⇒ 5
See also: arg XREFarg.
-- : arg (Z)
-- : angle (Z)
Compute the argument, i.e., angle of Z.
This is defined as, THETA = ‘atan2 (Y, X)’, in radians.
For example:
arg (3 + 4i)
⇒ 0.92730
See also: abs XREFabs.
-- : conj (Z)
Return the complex conjugate of Z.
The complex conjugate is defined as ‘conj (Z)’ = X - IY.
See also: real XREFreal, imag XREFimag.
-- : cplxpair (Z)
-- : cplxpair (Z, TOL)
-- : cplxpair (Z, TOL, DIM)
Sort the numbers Z into complex conjugate pairs ordered by
increasing real part.
The negative imaginary complex numbers are placed first within each
pair. All real numbers (those with ‘abs (imag (Z) / Z) < TOL’) are
placed after the complex pairs.
TOL is a weighting factor which determines the tolerance of
matching. The default value is 100 and the resulting tolerance for
a given complex pair is ‘100 * eps (abs (Z(i)))’.
By default the complex pairs are sorted along the first
non-singleton dimension of Z. If DIM is specified, then the
complex pairs are sorted along this dimension.
Signal an error if some complex numbers could not be paired.
Signal an error if all complex numbers are not exact conjugates (to
within TOL). Note that there is no defined order for pairs with
identical real parts but differing imaginary parts.
cplxpair (exp (2i*pi*[0:4]'/5)) == exp (2i*pi*[3; 2; 4; 1; 0]/5)
-- : imag (Z)
Return the imaginary part of Z as a real number.
See also: real XREFreal, conj XREFconj.
-- : real (Z)
Return the real part of Z.
See also: imag XREFimag, conj XREFconj.