Sort complex numbers into complex conjugate pairs
Syntax
Description
B = cplxpair(A)
sorts the elements along different dimensions of a complex array, grouping together complex conjugate pairs.
The conjugate pairs are ordered by increasing real part. Within a pair, the element with negative imaginary part comes first. The purely real values are returned following all the complex pairs. The complex conjugate pairs are forced to be exact complex conjugates. A default tolerance of 100*eps
relative to abs(A(i))
determines which numbers are real and which elements are paired complex conjugates.
If A
is a vector, cplxpair(A)
returns A
with complex conjugate pairs grouped together.
If A
is a matrix, cplxpair(A)
returns A
with its columns sorted and complex conjugates paired.
If A
is a multidimensional array, cplxpair(A)
treats the values along the first non-singleton dimension as vectors, returning an array of sorted elements.
B = cplxpair(A,tol)
overrides the default tolerance.
B = cplxpair(A,[],dim)
sorts A
along the dimension specified by scalar dim.
B = cplxpair(A,tol,dim)
sorts A
along the specified dimension and overrides the default tolerance.
Diagnostics
If there are an odd number of complex numbers, or if the complex numbers cannot be grouped into complex conjugate pairs within the tolerance, cplxpair
generates the error message
No comments:
Post a Comment