### Question:
EllipticIIRDesigner extends AbstractIIRDesigner { @Override protected int calculateFilterOrder(FilterType type, double[] wp, double[] ws, double gpass, double gstop, boolean analog) throws BadFilterParametersException { double[] passb; double[] stopb; if (!analog) { passb = prewarpFrequencies(wp); stopb = prewarpFrequencies(ws); } else { passb = wp.clone(); stopb = ws.clone(); } double frequencyRatio = calculateFrequencyRatio(type, passb, stopb, gpass, gstop); double GSTOP = Math.pow(10.0, 0.1 * Math.abs(gstop)); double GPASS = Math.pow(10.0, 0.1 * Math.abs(gpass)); double arg1 = Math.sqrt((GPASS - 1.0) / (GSTOP - 1.0)); double arg0 = 1.0 / frequencyRatio; double[] d0 = new double[2]; double[] d1 = new double[2]; d0[0] = SpecialMath.calculateCompleteEllipticIntegralOfTheFirstKind(arg0 * arg0); d0[1] = SpecialMath.calculateCompleteEllipticIntegralOfTheFirstKind(1 - arg0 * arg0); d1[0] = SpecialMath.calculateCompleteEllipticIntegralOfTheFirstKind(arg1 * arg1); d1[1] = SpecialMath.calculateCompleteEllipticIntegralOfTheFirstKind(1 - arg1 * arg1); int filterOrder = (int)(Math.ceil(d0[0] * d1[1] / (d0[1] * d1[0]))); if (filterOrder == 0) throw new BadFilterParametersException("Filter order is zero - check the input parameters!"); return filterOrder; }    }### Answer:
@Test public void testCalculateFilterOrder() throws BadFilterParametersException { int filterOrder; filterOrder = iirdesigner.calculateFilterOrder(FilterType.LOWPASS, 0.4, 0.7, 3, 40, false); assertEquals(3, filterOrder); filterOrder = iirdesigner.calculateFilterOrder(FilterType.HIGHPASS, 0.7, 0.3, 1, 80, false); assertEquals(5, filterOrder); filterOrder = iirdesigner.calculateFilterOrder(FilterType.BANDSTOP, new double[] {0.5, 0.8}, new double[] {0.6, 0.7}, 0.5, 100, false); assertEquals(6, filterOrder); filterOrder = iirdesigner.calculateFilterOrder(FilterType.BANDPASS, new double[] {0.6, 0.7}, new double[] {0.55, 0.8}, 0.5, 100, true); assertEquals(7, filterOrder); }