Navigation

Operators and Keywords

Function List:

C++ API

: 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)

Demonstration 1

The following code

 [ cplxpair(exp(2i*pi*[0:4]'/5)), exp(2i*pi*[3; 2; 4; 1; 0]/5) ]

Produces the following output

ans =

  -0.80902 - 0.58779i  -0.80902 - 0.58779i
  -0.80902 + 0.58779i  -0.80902 + 0.58779i
   0.30902 - 0.95106i   0.30902 - 0.95106i
   0.30902 + 0.95106i   0.30902 + 0.95106i
   1.00000 + 0.00000i   1.00000 + 0.00000i

Package: octave