functionreorderZeros
Extract real and conjugate complex elements from a complex vector
Extends from Modelica.Icons.Function (Icon for functions).
Information
Syntax
reorderedZero = Internal.reorderZeros(complexVector);
(reorderedZeros, nRealZeros) = Internal.reorderZeros(complexVector,
name="complexVector");
Description
Function reorderZeros(..) reorders the zeros from the Complex vector "complexVector" such that the returned Complex vector reorderedZeros contains first all real Zeros and afterwards the conjugate complex zero pairs. It is required that all elements of complexVector define either a real zero (complexVector[i].im=0) or a conjugate complex zero pair (complexVector[i].re == complexVector[i+1].re and complexVector[i].im == -complexVector[i+1].im). The optional input argument "name" is used as name of "complexVector" in error messages.
The function returns the vector element reordered, as well as the number of real zeros (nRealZeros).
Example
// c = {0, 1+2*j, 1-2*j, 2, -3, -1-1*j, -1+1*j};
Real complexZeros[:] = fill(Complex(0), integer((size(c,1)-n)/2));
algorithm
(reorderedZeros, nRealZeros) := reorderZeros(c);
// reorderedZeros = {0, 2, (-3), 1+2*j, 1-2*j, -1+1*j, -1-1*j}
// nRealZeros = 3
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Complex[:] | complexVector | Zeros of a polynomial with real coefficients, e.g., eigen values of a real matrix | |
| String | name | "complexVector" | Name of complexVector to be used in error message |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Complex[size(complexVector, 1)] | reorderedZeros | Reordered zeros | |
| Integer | nRealZeros | numberOfRealZeros(complexVector) | Number of real zeros (reorderedZeros[1:nRealZeros] are the real zeros) |