functionsortEigenvalue

Sort elements of Eigenvalue-record depending on the eigenvalues

Extends from Modelica.Icons.Function (Icon for functions).

Information

Syntax

           sorted_v = Vectors.sort(v);
(sorted_v, indices) = Vectors.sort(v, ascending=true);

Description

Function sort(..) sorts a Real vector v in ascending order and returns the result in sorted_v. If the optional argument "ascending" is false, the vector is sorted in descending order. In the optional second output argument the indices of the sorted vector with respect to the original vector are given, such that sorted_v = v[indices].

Example

  (v2, i2) := Vectors.sort({-1, 8, 3, 6, 2});
       -> v2 = {-1, 2, 3, 6, 8}
          i2 = {1, 5, 3, 4, 2}

Inputs

TypeNameDefaultDescription
Eigenvalue[:]evVector to be sorted
Booleanascendingtrue= true if ascending order, otherwise descending order
BooleansortFrequencytrueTrue, if sorting is first for imaginary then for real value, otherwise sorting is for absolute value

Outputs

TypeNameDefaultDescription
Eigenvalue[size(ev, 1)]sorted_evevSorted vector
Integer[size(ev, 1)]indices1:size(ev, 1)sorted_ev = ev[indices]