final double[][] coefsMatExp = new double[][] { {0., 0., 1. / 7., yValues[0][0] }, {0., 0., 1. / 13., yValues[1][0] }, {0., 0., 1. / 7., yValues[0][1] }, {0., 0., 1. / 13., yValues[1][1] },
{0., 0., 1. / 7., yValues[0][2] }, {0., 0., 1. / 13., yValues[1][2] }, {0., 0., 1. / 7., yValues[0][3] }, {0., 0., 1. / 13., yValues[1][3] },
{0., 0., 1. / 7., yValues[0][4] }, {0., 0., 1. / 13., yValues[1][4] } };
PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D();
PiecewisePolynomialInterpolator interp = new ConstrainedCubicSplineInterpolator();
PiecewisePolynomialResult result = interp.interpolate(xValues, yValues);
assertEquals(result.getDimensions(), 2);
assertEquals(result.getNumberOfIntervals(), 5);
assertEquals(result.getOrder(), 4);
for (int i = 0; i < result.getNumberOfIntervals() * result.getDimensions(); ++i) {
for (int j = 0; j < result.getOrder(); ++j) {
final double ref = Math.abs(coefsMatExp[i][j]) == 0. ? 1. : Math.abs(coefsMatExp[i][j]);
assertEquals(result.getCoefMatrix().getData()[i][j], coefsMatExp[i][j], ref * EPS);
}
}
final int nKeys = 101;
for (int i = 0; i < nKeys; ++i) {
final double key = 1. + 5. / (nKeys - 1) * i;
final double ref = key / 7. + 1 / 11.;
assertEquals(function.evaluate(result, key).getData()[0], ref, ref * EPS);
// System.out.println(key + "\t" + function.evaluate(result, key).getData()[0] + "\t" + function.evaluate(result, key).getData()[0]);
}
}