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

  1. function [v,b] = splpp(tx,a)
  2. % SPLPP    Convert locally from B-form to pp-form.
  3. %
  4. %    [v,b] = splpp(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 B-spline coefficients
  9. %   b(.,1:k)  relevant for the interval  [tx(.,k-1),0]  (with respect
  10. %  to the knot sequence [tx(.,1:k-1),0,...,0] ), with  [ ,k]:=size(a) . 
  11. %
  12. %   It is assumed that  tx(.,k-1) < 0 <= tx(.,k) .
  13. %
  14. %  From this, computes v(j) := D^{k-j}s(0-)/(k-j)! , j=1,...,k , with  s  the 
  15. %  spline described by the given knots and coefficients.
  16.  
  17.  
  18. % C. de Boor / latest change: Feb.25, 1989
  19. % Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.
  20.  
  21.  
  22. [junk,k]=size(a); km1=k-1;b=a;
  23.    for r=1:km1;
  24.       for i=km1:-1:r;
  25.          b(:,i+1) = (tx(:,i+k-r)*b(:,i)-tx(:,i)*b(:,i+1))/(tx(:,i+k-r)-tx(:,i));
  26.       end
  27.    end
  28. end
  29.  
  30. %  Use differentiation at  0  to generate the derivatives
  31.  
  32. v=b;
  33. for r=1:km1;
  34.    factor = (k-r)/r;
  35.    for i=1:k-r;
  36.       v(:,i) = (v(:,i) - v(:,i+1))*factor./tx(:,i+r-1);
  37.    end
  38. end
  39.  
  40. % Note: the first B-spline has knots tx_0,...,tx_k, but its evaluation only
  41. % uses tx_1,...,tx_k . Similarly, the evaluation of the last, or k-th, B-spline
  42. % only requires its `interior' knots  tx_k,...,tx_(2k-2) . 
  43. %
  44. % Since the first B-spline has knots  tx_0,...,tx_k , we have  t_j=tx_(j-1) in
  45. % the usual formulae. E.g., in the first step, we overwrite
  46. %  a(j)  by  (-tx_(j-1)a(j)+tx_(j+k-2)a(j-1))/(-tx_...+tx_...) , 
  47. % and do this for  j=2,...,k.
  48.