- backward_xs = [x-(offset_b*h) : h : x];
-
- ## We'll always have at least one forward point, so start this vector
- ## from (x + h) and include `x` itself in the backward points.
- forward_xs = [x+h : h : x+(offset_f*h)];
+ ## Zero out the coefficients for terms that won't appear. We compute
+ ## where `x` is, and we just computed how far back/forward we need to
+ ## look from `x`, so we just need to make the rest zeros.
+ x_idx = find(xs == x);
+ first_nonzero_idx = x_idx - offset_b;
+ last_nonzero_idx = x_idx + offset_f;
+ leading_zero_count = first_nonzero_idx - 1;
+ leading_zeros = zeros(1, leading_zero_count);
+ trailing_zero_count = length(xs) - last_nonzero_idx;
+ trailing_zeros = zeros(1, trailing_zero_count);