### Question:
FilterZerosPolesGain { protected FilterCoefficients convertToBACoefficients() { ComplexPolynomial numeratorPoly; ComplexPolynomial denominatorPoly; Complex[] complexNumeratorCoeffs; Complex[] complexDenominatorCoeffs; double[] realNumeratorCoeffs; double[] realDenominatorCoeffs; if (getZeros().length > 0) { numeratorPoly = ComplexPolynomial.rootsToPolynomial(getZeros()); complexNumeratorCoeffs = numeratorPoly.getCoefficients(); } else complexNumeratorCoeffs = new Complex[] { new Complex(1.0, 0) }; denominatorPoly = ComplexPolynomial.rootsToPolynomial(getPoles()); complexDenominatorCoeffs = denominatorPoly.getCoefficients(); realNumeratorCoeffs = new double[complexNumeratorCoeffs.length]; realDenominatorCoeffs = new double[complexDenominatorCoeffs.length]; for (int i = 0; i < complexNumeratorCoeffs.length; i++) realNumeratorCoeffs[i] = gain * complexNumeratorCoeffs[i].getReal(); for (int i = 0; i < complexDenominatorCoeffs.length; i ++) realDenominatorCoeffs[i] = complexDenominatorCoeffs[i].getReal(); FilterCoefficients coeffs = new FilterCoefficients(realNumeratorCoeffs, realDenominatorCoeffs); return coeffs; } protected  FilterZerosPolesGain(Complex[] zeros, Complex[] poles, double gain); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void testConvertToABCoefficients() { Complex[] zeros = new Complex[0]; Complex[] poles = new Complex[] {new Complex(-0.08517040, 0.94648443), new Complex(-0.20561953, 0.39204669), new Complex(-0.20561953, -0.39204669), new Complex(-0.08517040, -0.94648443) }; double gain = 0.125297161626; FilterZerosPolesGain zpk1 = new FilterZerosPolesGain(zeros, poles, gain); double[] pythonB = new double[] {0.12529716}; double[] pythonA = new double[] {1.00000000, 0.58157986, 1.16911757, 0.40476795, 0.17698695}; FilterCoefficients pycoeffs = new FilterCoefficients(pythonB, pythonA); FilterCoefficients coeffs = zpk1.convertToBACoefficients(); assertEquals(pycoeffs, coeffs, 1e-6); }
@Test public void testConvertToABCoefficients2() { Complex[] zeros = new Complex[0]; Complex[] poles = new Complex[] {new Complex(0.4, 0.2), new Complex(0.5, 0.3)}; double gain = 1.0; FilterZerosPolesGain zpk1 = new FilterZerosPolesGain(zeros, poles, gain); double[] pythonB = new double[] {1.0}; double[] pythonA = new double[] {1, -0.9, 0.14}; FilterCoefficients pycoeffs = new FilterCoefficients(pythonB, pythonA); FilterCoefficients coeffs = zpk1.convertToBACoefficients(); assertEquals(pycoeffs, coeffs, 1e-6); }