function detext
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% determines the extended inner bsplines & computes coefficients
% n                  : degree
% D=[i xx(i)]        : all b-splines supporting the domain 
% bb                 : extended(3), inner(2) and outer(1) b-splines
% gi, gj             : inner and outer b-splines
% E                  : extended matrix
%
% Created by G.Apaydin in June 2006
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global gi gj bb D n E;
F=sparse(length(gi),length(gj));cc=bb;
%coefficients up to degree 5
e={[2,-1],[3,-3,1],[4,-6,4,-1],...
    [5,-10,10,-5,1],[6,-15,20,-15,6,-1]};ee=e{n};
NN=1:n+1;
if length(gj)>0
    for k=1:length(gj)
        q=D(gj(k),1);
        %determine extended bsplines       
        if q==1,
            if bb(q+NN)==2,cc(q+NN)=3;
                for i=NN,F(gi==q+i,k)=ee(i);end
            end
        elseif bb(q-NN)==2,cc(q-NN)=3;
            for i=NN,F(gi==q-i,k)=ee(i);end
        else display('Hata extension');
        end
    end
end
E=[speye(length(gi)) F];bb=cc;