home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 5.ddi / SPLINES.DI$ / PPCUT.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.3 KB  |  41 lines

  1. function pc=ppcut(pp,bounds)
  2. % PPCUT    Cut down a pp to a given interval.
  3. %
  4. %      pc = ppcut(pp,bounds)
  5. %
  6. %  returns the restriction of  pp  to the interval  [bounds(1) .. bounds(2)]
  7.  
  8. % C. de Boor / latest change: Feb.25, 1989
  9. % C. de Boor / latest change: May 27, 1991  interval notation changed
  10. % Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.
  11.  
  12. xl=bounds(1);xr=bounds(2);if xl>xr,xl=xr;xr=bounds(1);end
  13.  
  14. [breaks,coefs,l,k,d]=ppbrk(pp);
  15.  
  16. %  the first pol. piece is  jl , the one responsible for argument  xl 
  17.  
  18. jl=l;index=find(breaks(2:l)>xl);        % note that the resulting  index  is 
  19. if (~isempty(index)), jl=index(1); end  % shifted down by one because of
  20.                                         % break(2: ...
  21.  
  22. %  if xl ~= breaks(jl), recenter the pol.coeffs.
  23. x=xl-breaks(jl);
  24. if x ~= 0,
  25.    a=coefs(d*jl+[1-d:0],:);
  26.    for ii=k:-1:2;
  27.       for i=2:ii;
  28.          a(:,i)=x*a(:,i-1)+a(:,i);
  29.       end
  30.    end
  31.    coefs(d*jl+[1-d:0],:)=a;
  32. end
  33.  
  34. %  the last pol. piece is  jr , the one responsible for argument  xr .
  35. jr=l;index=find(breaks(2:l+1)>=xr);      % note that the resulting  index  is 
  36. if (~isempty(index)), jr=index(1); end  % shifted down by one because of
  37.                                         % break(2: ...
  38.  
  39. %  put together the cut-down  pp
  40. pc=ppmak([xl breaks(jl+1:jr) xr], coefs(d*(jl-1)+[1:d*(jr-jl+1)],:),d);
  41.