This function constructs a polynomial from given zeros (also called roots). The zeros are defined as a vector of Complex numbers. Since only polynomials with real coefficients are supported, complex zeros must be defined as conjugate complex pairs. It is required that complex conjugate pairs must directly follow each other. An error occurs if this is not the case.
The polynomial
y = (s - 1) * ( s - (2+3j) ) * (s - (2-3j))
with j=sqrt(-1), is defined as
import Modelica_LinearSystems2.Math.Polynomial Polynomial( {Complex(1), Complex(2, 3), Complex(2, -3)} ); // x^3 - 5*x^2 + 17*x - 13
function fromZeros import Modelica; import Modelica_LinearSystems2.Math.Polynomial; import Modelica.Utilities.Streams; import Complex; input Complex roots[:] "Zeros of polynomial (must be real or conjugate complex pairs)"; output Polynomial p(redeclare Real c[size(roots, 1) + 1]) "Polynomial that corresponds to the zeros"; end fromZeros;