summaryrefslogtreecommitdiff
path: root/macros/cplxpair.sci
diff options
context:
space:
mode:
Diffstat (limited to 'macros/cplxpair.sci')
-rw-r--r--macros/cplxpair.sci52
1 files changed, 26 insertions, 26 deletions
diff --git a/macros/cplxpair.sci b/macros/cplxpair.sci
index 16fceac..d7e8a38 100644
--- a/macros/cplxpair.sci
+++ b/macros/cplxpair.sci
@@ -1,30 +1,30 @@
-/*Description
- 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.
- and the resulting tolerance for a given complex pair is 100 * eps (abs (z(i))).
- 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
-Calling Sequence
- cplxpair (z)
- cplxpair (z, tol)
- cplxpair (z, tol, dim)
-Parameters:
- z is a matrix or vector.
- tol is a weighting factor which determines the tolerance of matching. The default value is 100.
- 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.
-Dependencies: ipermute
-Example:
- The following code
- [ cplxpair(exp(2*%i*%pi*[0:4]'/5)), exp(2*%i*%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
-*/
function zsort = cplxpair (z, tol, dim)
+// Description
+// 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.
+// and the resulting tolerance for a given complex pair is 100 * eps (abs (z(i))).
+// 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
+// Calling Sequence
+// cplxpair (z)
+// cplxpair (z, tol)
+// cplxpair (z, tol, dim)
+// Parameters:
+// z is a matrix or vector.
+// tol is a weighting factor which determines the tolerance of matching. The default value is 100.
+// 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.
+// Dependencies: ipermute
+// Example:
+// The following code
+// [ cplxpair(exp(2*%i*%pi*[0:4]'/5)), exp(2*%i*%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
+
if (nargin < 1)
error("Invalid inputs");
end