if (!isControllableCanonical(system)) {
throw new IllegalArgumentException("System must be in controllable-canonical form");
}
EigenvalueDecomposition eig = new Matrix(MU.convert(system.getA(0f))).eig();
double[] eigReal = eig.getRealEigenvalues();
double slowest = eigReal[0];
for (int i = 1; i < eig.getRealEigenvalues().length; i++) {
if (Math.abs(eigReal[i]) < Math.abs(slowest)) slowest = eigReal[i];
}
//may be repeated / complex conjugate so change all slowest real eigenvalues
for (int i = 0; i < eigReal.length; i++) {
if (Math.abs(eigReal[i] - slowest) < .0001*Math.abs(slowest)) eigReal[i] = -1d / (double) tau;
}
//coefficients of new transfer function polynomial ...
double[] eigImag = eig.getImagEigenvalues();
float[][] poly = new float[][]{new float[]{1f, (float) -eigReal[0]}, new float[]{0f, (float) -eigImag[0]}};
for (int i = 1; i < eigReal.length; i++) {
poly = prod(poly, new float[][]{new float[]{1f, (float) -eigReal[i]}, new float[]{0f, (float) -eigImag[i]}});
}