@Override
public Map<double[], Double> getNodeSensitivitiesForValue(final InterpolatorNDDataBundle data, final double[] x) {
ArgumentChecker.notNull(data, "data");
ArgumentChecker.notNull(x, "x array");
ArgumentChecker.isTrue(data instanceof RadialBasisFunctionInterpolatorDataBundle, "RadialBasisFunctionInterpolatorNDSensitivityCalculator needs a RadialBasisFunctionInterpolatorDataBundle");
final RadialBasisFunctionInterpolatorDataBundle radialData = (RadialBasisFunctionInterpolatorDataBundle) data;
final List<Pair<double[], Double>> rawData = radialData.getData();
final Function1D<Double, Double> basisFunction = radialData.getBasisFunction();
final int n = rawData.size();
double[] xi;
final double[] phi = new double[n];
double normSum = 0;
final double[] phiNorm = new double[n];
for (int i = 0; i < n; i++) {
xi = rawData.get(i).getFirst();
phi[i] = basisFunction.evaluate(DistanceCalculator.getDistance(x, xi));
if (radialData.isNormalized()) {
normSum += phi[i];
double sum = 0;
double[] xj;
for (int j = 0; j < n; j++) {
xj = rawData.get(j).getFirst();
sum += basisFunction.evaluate(DistanceCalculator.getDistance(xj, xi));
}
phiNorm[i] = sum;
}
}
final double[] temp = radialData.getDecompositionResult().solve(phi);
double sense = 0;
final Map<double[], Double> res = new HashMap<>(n);
for (int i = 0; i < n; i++) {
if (radialData.isNormalized()) {
sense = temp[i] * phiNorm[i] / normSum;
} else {
sense = temp[i];
}
res.put(rawData.get(i).getFirst(), sense);