function re = NonBSpline( m, t, x0 )
% NonBSpline Computes the value of B spline basis at x0 by the recurrence formula for
% the non-uniform B spline.
%
% Usage:    re = NonBSpline( m, t, x0 );
%
% Inputs:
%   m       the order of splines
%   t       the partition (the number of entris in t is m+1)
%   x0      the point for computing
%
% Outputs: 
%   re      the value of B spline at x0

% See   http://www.ncrg.aston.ac.uk/Projects/HNLApprox/
%       http://www.nonlinear-approx.info/
if x0<t(1) | x0>t(end)
    re=0;
    return;
end

if m==1
    re=0;
    if x0>=t(1) & x0<t(end)
     re=1;
     return;
    end
   return;
end

re=(x0-t(1))/(t(end-1)-t(1))*NonBSpline(m-1,t(1:end-1),x0)+(t(end)-x0)/(t(end)-...
    t(2))*NonBSpline(m-1,t(2:end),x0);

% Zhiqiang Xu (2009)