BasisFunctionGenerator { protected Function1D<Double, Double> generate(BasisFunctionKnots data, final int index) { ArgumentChecker.notNull(data, "data"); ArgumentChecker.isTrue(index >= 0 && index < data.getNumSplines(), "index must be in range {} to {} (exclusive)", 0, data.getNumSplines()); return generate(data.getKnots(), data.getDegree(), index); }  @Deprecated List<Function1D<Double, Double>> generateSet(final double xa, final double xb, final int nKnots, final int degree); @Deprecated List<Function1D<Double, Double>> generateSet(final double[] internalKnots, final int degree); List<Function1D<Double, Double>> generateSet(BasisFunctionKnots knots); List<Function1D<double[], Double>> generateSet(BasisFunctionKnots[] knots); @Deprecated List<Function1D<double[], Double>> generateSet(final double[] xa, final double[] xb, final int[] nKnots, final int[] degree);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testFunctionIndexOutOfRange1() { BasisFunctionKnots k = BasisFunctionKnots.fromKnots(KNOTS, 2); GENERATOR.generate(k, -1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testFunctionIndexOutOfRange2() { BasisFunctionKnots k = BasisFunctionKnots.fromKnots(KNOTS, 5); int nS = k.getNumSplines(); GENERATOR.generate(k,nS); }
@Test public void testZeroOrder() { BasisFunctionKnots knots = BasisFunctionKnots.fromInternalKnots(KNOTS, 0); final Function1D<Double, Double> func = GENERATOR.generate(knots, 4); assertEquals(0.0, func.evaluate(3.5), 0.0); assertEquals(1.0, func.evaluate(4.78), 0.0); assertEquals(1.0, func.evaluate(4.0), 0.0); assertEquals(0.0, func.evaluate(5.0), 0.0); }
@Test public void testFirstOrder() { BasisFunctionKnots knots = BasisFunctionKnots.fromInternalKnots(KNOTS, 1); final Function1D<Double, Double> func = GENERATOR.generate(knots, 3); assertEquals(0.0, func.evaluate(1.76), 0.0); assertEquals(1.0, func.evaluate(3.0), 0.0); assertEquals(0, func.evaluate(4.0), 0.0); assertEquals(0.5, func.evaluate(2.5), 0.0); }
@Test public void testSecondOrder() { BasisFunctionKnots knots = BasisFunctionKnots.fromInternalKnots(KNOTS, 2); final Function1D<Double, Double> func = GENERATOR.generate(knots, 3); assertEquals(0.0, func.evaluate(0.76), 0.0); assertEquals(0.125, func.evaluate(1.5), 0.0); assertEquals(0.5, func.evaluate(2.0), 0.0); assertEquals(0.75, func.evaluate(2.5), 0.0); assertEquals(0.0, func.evaluate(4.0), 0.0); }
@Test public void testThirdOrder() { BasisFunctionKnots knots = BasisFunctionKnots.fromInternalKnots(KNOTS, 3); final Function1D<Double, Double> func = GENERATOR.generate(knots, 3); assertEquals(0.0, func.evaluate(-0.1), 0.0); assertEquals(1. / 6., func.evaluate(1.0), 0.0); assertEquals(2. / 3., func.evaluate(2.0), 0.0); assertEquals(1 / 48., func.evaluate(3.5), 0.0); assertEquals(0.0, func.evaluate(4.0), 0.0); }