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

  1. function v=ppual(pp,xx)
  2. % PPUAL    Evaluate a pp.
  3. %
  4. %      v = ppual(pp,xx)
  5. %
  6. %  returns the value of the pp function  pp  at  xx.
  7.  
  8. % C. de Boor / latest change: June 19, 1989
  9. % C. de Boor / latest change: December 1, 1990 (correct misprint in last line)
  10. % Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.
  11.  
  12.  
  13. %  if necessary, sort  xx 
  14. xs=xx(:)';ix=length(xs);tosort=0;
  15. if (length(find(diff(xs)<0))>0),
  16.    tosort=1;[xs,indx]=sort(xs);
  17. end
  18.  
  19. %  take apart  pp
  20. [x,c,l,k,d]=ppbrk(pp);
  21.  
  22. % for each data point, compute its breakpoint interval
  23. index=max([sorted(x(1:l),xs);ones(1,ix)]);
  24.  
  25. % now go to local coordinates
  26. xs=xs-x(index);
  27. % ... and apply nested multiplication:
  28. if (d>1),
  29.    ones(d,1)*xs; xs=ans(:)';
  30.    1+d*ones(d,1)*index+[-d:-1]'*ones(1,ix); index=ans(:);
  31. end
  32. vv=c(index,1)';
  33. for i=2:k,
  34.    vv = xs.*vv + c(index,i)';
  35. end
  36.  
  37. v=zeros(d,length(xx));v(:)=vv;
  38. if tosort>0,[junk,indx]=sort(indx); v=v(:,indx);end
  39.  
  40.