# .Modelica_LinearSystems2.Internal.extractRealZeros

## Information

#### Syntax

```                realZeros = Matrices.extractRealZeros(complexVector, numberOfRealRoots);
(realZeros, complexZeros) = Matrices.extractRealZeros(
complexVector,
numberOfRealRoots,
name="complexVector");
```

#### Description

This function extracts the real zeros from the Complex vector "complexVector". 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 second argument "numberOfRealZeros" is determined by a function call of Internal.numberOfRealZeros(). The optional input argument "name" is used as name of "complexVector" in error messages.

The function returns the real elements of complexVector in vector "realZeros" and the real and imaginary part of a conjugate complex zero pair in matrix "complexZeros[:]".

#### Example

```  // c = {0; 1+2j; 1-2j; 2; -3; -1-j; -1+j};
Integer n = numberOfRealZeros(c);
Real realZeros[n];
Real complexZeros[:] = fill(Complex(0), integer((size(c,1)-n)/2));
algorithm
(realZeros, complexZeros) := extractRealZeros(c, n);
-> realZeros    = {0, 2, (-3)};
complexZeros = { 1+2j,
-1+j}
```

#### Interface

```function extractRealZeros
import Modelica_LinearSystems2.Math.Complex;
input Complex complexVector[:] "Zeros of a polynomial with real coefficients, e.g., eigen values of a real matrix";
input Integer numberOfRealZeros "Number of real zeros of ComplexVector determined with function numberOfRealZeros";
input String name = "complexVector" "Name of complexVector to be used in error message";
output Real realZeros[numberOfRealZeros] "Real zeros of complexVector";
output Complex complexZeros[:] = fill(Complex(0), integer((size(complexVector, 1) - numberOfRealZeros) / 2)) "Complex zeros without the corresponding conjugate complex pair element";
end extractRealZeros;
```

Generated at 2020-04-02T01:37:38Z by OpenModelicaOpenModelica 1.16.0~dev-259-g8a5138f using GenerateDoc.mos