% DIFEQSET	Used by DIFEQDEM.
echo off
                                         %latest change: December 25, 1989
% Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.

   % We get a refined break sequence from current  z  via  newknt
   breaks = newknt(sp2pp(z),ninterv+1);
   knots = augknt(breaks,4,2);
   n = length(knots)-k;
   
   % ... and generate the corresponding set of collocation points.
   ninterv = length(breaks)-1;
   (breaks(2:ninterv+1)+breaks(1:ninterv))/2;
   ans'*[1 1] + diff(breaks)'*gauss;
   colpnts = sort(ans(:)');
   points = [0,colpnts,1];
   
   % We use  spcol  to supply the matrix
   colmat = spcol(knots,k,sort([points points points]));
   
   % ... and use our current approximate solution  z  as the initial guess:
   intmat = colmat([2 1+[1:(n-2)]*3,1+(n-1)*3],:);
   y = spmak(knots,[0 fnval(z,colpnts) 0]/intmat');

echo on
