BasisFunctionKnots { public static BasisFunctionKnots fromUniform(double xa, double xb, int nKnots, int degree) { ArgumentChecker.isTrue(xb > xa, "Require xb > xa, values are xa = {}, xb = {}", xa, xb); ArgumentChecker.notNegative(degree, "degree"); ArgumentChecker.isTrue(nKnots - degree > 0, "Require at least {} knots for degree {}, only given {}", degree + 1, degree, nKnots); int nTotalKnots = nKnots + 2 * degree; int nSplines = nKnots + degree - 1; double[] knots = new double[nTotalKnots]; double dx = (xb - xa) / (nKnots - 1); for (int i = 0; i < degree; i++) { knots[i] = (i - degree) * dx + xa; knots[degree + nKnots + i] = xb + dx * (i + 1); } for (int i = 0; i < nKnots - 1; i++) { knots[i + degree] = xa + i * dx; } knots[nKnots + degree - 1] = xb; return new BasisFunctionKnots(knots, degree, nSplines); } private  BasisFunctionKnots(double[] knots, int degree, int nSplines); static BasisFunctionKnots fromUniform(double xa, double xb, int nKnots, int degree); static BasisFunctionKnots fromInternalKnots(double[] internalKnots, int degree); static BasisFunctionKnots fromKnots(double[] knots, int degree); double[] getKnots(); int getNumKnots(); int getDegree(); int getNumSplines();  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testWrongOrderUniform() { BasisFunctionKnots.fromUniform(2.0, 1.0, 10, 3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDegreeToHigh1() { BasisFunctionKnots.fromUniform(0.0, 10.0, 11, 11); }