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

  1. function [v,b] = sprpp(tx,a)
  2. % SPRPP    Convert locally from B-form to pp-form.
  3. %
  4. %    [v,b] = sprpp(tx,a)
  5. %
  6. %  uses knot insertion to derive from the B-spline coefficients
  7. %  a(.,:)  relevant for the interval  [tx(.,k-1), tx(.,k)]  (with respect
  8. %  to the knot sequence  tx(.,1:2(k-1)) )  the polynomial coefficients
  9. %   v(.,1:k)  relevant for the interval  [0,tx(.,k)] . Here, 
  10. %
  11. %   [ ,k] := size(a) . Also, it is assumed that  tx(.,k-1) <= 0 < tx(.,k) .
  12. %
  13. %  In the process, uses repeated insertion of  0  to derive, in  b(.,1:k) ,
  14. %  the B-spline coefficients relevant for the interval  [0,tx(.,k)]  (with 
  15. %  respect to the knot sequence  [0,...,0,tx(.,k:2*(k-1))]) .
  16.  
  17. % C. de Boor / latest change: Feb.25, 1989
  18. % Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.
  19.  
  20.  
  21. [junk,k]=size(a); km1=k-1;b=a;
  22. for r=1:km1;
  23.    for i=1:k-r;
  24.       b(:,i) =(tx(:,i+km1).*b(:,i)-tx(:,i+r-1).*b(:,i+1))./...
  25.                (tx(:,i+km1)-tx(:,i+r-1));
  26.    end
  27. end
  28.  
  29. %  Use differentiation at  0  to generate the derivatives
  30.  
  31. v=b;
  32. for r=2:k;
  33.    factor = (k-r+1)/(r-1);
  34.    for i=k:-1:r;
  35.       v(:,i) = (v(:,i) - v(:,i-1))*factor./tx(:,i+k-r);
  36.    end
  37. end
  38.  
  39. v = v(:,k:-1:1);
  40.