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

  1. function pp=sp2pp(spline)
  2. % SP2PP    Convert from B-form to pp-form.
  3. %
  4. %     pp = sp2pp(spline)
  5. %
  6. %  converts the  spline  to its  pp  representation on the interval
  7. %                 [t(1),t(n+k)]
  8.  
  9. % C. de Boor / latest change: Aug.10, 1989
  10. % Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.
  11.  
  12.  
  13. %  Take apart the  spline
  14.  
  15. [t,a,n,k,d]=spbrk(spline);
  16.  
  17. %  and augment the knot sequence so that first and last knot each have
  18. %  multiplicity  k .
  19.  
  20. index=find(diff(t)>0);addl=k-index(1);addr=index(length(index))-n;
  21. if (addl>0|addr>0),
  22.    t=[t(1)*ones(1,addl) t(:)' t(n+k)*ones(1,addr)];
  23.    a=[zeros(d,addl) a zeros(d,addr)];
  24. end
  25.  
  26. %  From this, generate the pp description. 
  27.  
  28. inter=find( diff(t)>0 );l=length(inter);
  29. if (k>1)
  30.    ones(d,1)*inter;dinter=ans(:);
  31.    tx=ones(d*l,1)*[2-k:k-1]+dinter*ones(1,2*(k-1));tx(:)=t(tx);
  32.    tx=tx-t(dinter)'*ones(1,2*(k-1));
  33.    a=a(:);d*ones(d,1)*inter+[1-d:0]'*ones(1,l);dinter(:)=ans(:);
  34.    b=d*ones(d*l,1)*[1-k:0]+dinter*ones(1,k);b(:)=a(b);
  35.    c=sprpp(tx,b);
  36. else,a(:,inter);c=ans(:);
  37. end
  38.  
  39. %   put together the  pp
  40.  
  41. pp=ppmak([t(inter) t(inter(length(inter))+1)],c,d);
  42.