function D = NonUniB( a, b, m, p, L )
% NonUniB computes all non-unfirom B spline over the partition 'p'
%
% Usage:    D = NonUniB( a, b, m, p, L );
%
% Inputs:
%   a,b     the end points of the interval
%   m       the order of the spline
%   p       the partition
%   L       the number of the sampling of the functions
%
% Outputs:
%   D       the non-uniform B spline over the partition p (matrix, D(:,j) denots jth 
%           B spline basis) 

% See   http://www.ncrg.aston.ac.uk/Projects/HNLApprox/
%       http://www.nonlinear-approx.info/
x=linspace(a,b,L); 
num_knot=size(p,2);
for j=1:m-1
    newp(j)=a+(j-m)*(b-a)/L;
end
for j=1:num_knot
    newp(j+m-1)=p(j);
end
for j=1:m-1
    
    newp(num_knot+m-1+j)=b+j*(b-a)/L;
end

D=zeros(L,num_knot+m-2);
for j=1:num_knot+m-2
    
    t=newp(j:j+m);

    for k=1:L
     
           if x(k)>=t(1) & x(k)<=t(end)   D(k,j)=NonBSpline(m,t,x(k)); end;                   
        
    end
end
for j=1:num_knot+m-2
    D(:,j)=D(:,j)/norm(D(:,j));
end

% Zhiqiang Xu (2009)