function interpolateSumLinear(index, width, height, X, Y, V) {
const U = new Float64Array(width * height);
for (const i of index) {
const x = Math.floor(X[i] - 0.5);
const y = Math.floor(Y[i] - 0.5);
const dx = X[i] - 0.5 - x;
const dy = Y[i] - 0.5 - y;
for (const [a, b, w] of [
[x, y, (1 - dx) * (1 - dy)],
[x + 1, y, dx * (1 - dy)],
[x, y + 1, (1 - dx) * dy],
[x + 1, y + 1, dx * dy]
]) {
if (a >= 0 && b >= 0 && a < width && b < height)
U[a + width * b] += w * V[i];
}
}
return U;
}