function dyy = diffsplineeval(x, a, b, c, d, xx)
% Evaluate the derivative of a piecewise cubic spline at the points xx.

n = length(x) - 1;
dyy = zeros(size(xx));

for i = 1:n
    ix = xx >= x(i) & xx <= x(i + 1);
    dyy(ix) = b(i) + ...
        2 * c(i) * (xx(ix) - x(i)) + ...
        3 * d(i) * (xx(ix) - x(i)).^2;
end
