use of uk.ac.sussex.gdsc.core.math.interpolation.CustomTricubicInterpolatingFunction in project GDSC-SMLM by aherbert.
the class CubicSplineCalculatorTest method canComputeCoefficientsForGaussianFunction.
@Test
void canComputeCoefficientsForGaussianFunction() {
final int x = 4;
final int y = 4;
final int z = 4;
final double xscale = 1;
final double yscale = 0.5;
final double zscale = 2.0;
final double[] xval = SimpleArrayUtils.newArray(x, 0, xscale);
final double[] yval = SimpleArrayUtils.newArray(y, 0, yscale);
final double[] zval = SimpleArrayUtils.newArray(z, 0, zscale);
final double[][][] fval = createData(x, y, z, null);
final CustomTricubicInterpolatingFunction f1 = new CustomTricubicInterpolator().interpolate(xval, yval, zval, fval);
final double[] exp = new double[64];
f1.getSplineNode(1, 1, 1).getCoefficients(exp);
final CustomTricubicFunction f = CustomTricubicFunctionUtils.create(exp);
final CubicSplinePosition[] s = new CubicSplinePosition[4];
for (int i = 0; i < 4; i++) {
s[i] = new CubicSplinePosition((double) i / 3);
}
final double[][][] value = new double[4][4][4];
final double[] b = new double[64];
int count = 0;
for (int k = 0; k < 4; k++) {
for (int j = 0; j < 4; j++) {
for (int i = 0; i < 4; i++) {
value[i][j][k] = f.value(s[i], s[j], s[k]);
b[count++] = value[i][j][k];
}
}
}
final CubicSplineCalculator calc = new CubicSplineCalculator();
double[] obs = calc.compute(value);
Assertions.assertArrayEquals(exp, obs, 1e-6);
obs = calc.compute(b);
Assertions.assertArrayEquals(exp, obs, 1e-6);
}
Aggregations