BasisFunctionGenerator { @Deprecated public List<Function1D<Double, Double>> generateSet(final double xa, final double xb, final int nKnots, final int degree) { BasisFunctionKnots k = BasisFunctionKnots.fromUniform(xa, xb, nKnots, degree); return generateSet(k); }  @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 public void testTwoD() { BasisFunctionKnots knots1 = BasisFunctionKnots.fromInternalKnots(KNOTS, 2); BasisFunctionKnots knots2 = BasisFunctionKnots.fromInternalKnots(KNOTS, 3); List<Function1D<double[], Double>> set = GENERATOR.generateSet(new BasisFunctionKnots[] {knots1,knots2}); int index = FunctionUtils.toTensorIndex(new int[] {3,3}, new int[] {knots1.getNumSplines(),knots2.getNumSplines()}); Function1D<double[], Double> func = set.get(index); assertEquals(1. / 3., func.evaluate(new double[] {2.0,2.0}), 0.0); assertEquals(1. / 2., func.evaluate(new double[] {2.5,2.0}), 0.0); assertEquals(1. / 8./48., func.evaluate(new double[] {1.5,3.5}), 0.0); assertEquals(0.0, func.evaluate(new double[] {4.0,2.5}), 0.0); }
@Test public void testThreeD() { BasisFunctionKnots knots1 = BasisFunctionKnots.fromInternalKnots(KNOTS, 2); BasisFunctionKnots knots2 = BasisFunctionKnots.fromInternalKnots(KNOTS, 3); BasisFunctionKnots knots3 = BasisFunctionKnots.fromInternalKnots(KNOTS, 1); List<Function1D<double[], Double>> set = GENERATOR.generateSet(new BasisFunctionKnots[] {knots1,knots2,knots3}); int index = FunctionUtils.toTensorIndex(new int[] {3,3,3}, new int[] {knots1.getNumSplines(),knots2.getNumSplines(), knots3.getNumSplines()}); Function1D<double[], Double> func = set.get(index); assertEquals(1. / 3., func.evaluate(new double[] {2.0,2.0,3.0}), 0.0); }