function [c,xi] = spline_differentiation(c,xi)
% SPLINE_DIFFERENTIATION: derivative of a spline 
% [c,xi] = spline_differentiation(c,xi)
% changes coefficients c and knots xi
% according to the differentiation formula

% change to column vector (if necessary) 
xi = xi(:); 

% dimension and degree
n = length(xi)-length(c)-1; 

alpha = (xi(n+2:end-1)-xi(2:end-n-1))/n;
if min(alpha) == 0
   display('knot multiplicity exceeds degree');
   return
end

c = (c(2:end)-c(1:end-1))./alpha;
xi = xi(2:end-1);

