.Modelica_LinearSystems2.Internal.reorderZeros

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

Interface

function reorderZeros
  extends Modelica.Icons.Function;
  input Complex complexVector[:] "Zeros of a polynomial with real coefficients, e.g., eigen values of a real matrix";
  input String name = "complexVector" "Name of complexVector to be used in error message";
  output Complex reorderedZeros[size(complexVector, 1)] "Reordered zeros";
  output Integer nRealZeros = numberOfRealZeros(complexVector) "Number of real zeros (reorderedZeros[1:nRealZeros] are the real zeros)";
end reorderZeros;

Generated at 2024-12-26T19:25:54Z by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos