Fill the
weights array.
Let w_d denote the fraction of a pixel at which the sample
position p_d lies from the floored position pf_d in
dimension d. That is, the value at pf_d contributes
with (1 - w_d) to the sampled value; the value at
( pf_d + 1 ) contributes with w_d.
At every pixel, the total weight results from multiplying the weights of
all dimensions for that pixel. That is, the "top-left" contributing pixel
(position floored in all dimensions) gets assigned weight
(1-w_0)(1-w_1)...(1-w_n).
We work through the weights array starting from the highest dimension.
For the highest dimension, the first half of the weights contain the
factor (1 - w_n) because this first half corresponds to floored
pixel positions in the highest dimension. The second half contain the
factor w_n. In this first step, the first weight of the first
half gets assigned (1 - w_n). The first element of the second
half gets assigned w_n
From their, we work recursively down to dimension 0. That is, each half
of weights is again split recursively into two partitions. The first
element of the second partitions is the first element of the half
multiplied with (w_d). The first element of the first partitions
is multiplied with (1 - w_d).
When we have reached dimension 0, all weights will have a value assigned.