% CLENSHAW_SOB Clenshaw-like algorithm for Sobolev orthogonal polynomials % % Given the NxN matrix B=B_N of the Sobolev recurrence % coefficients, s=CLENSHAW_SOB(n,N,s,x,B,c) generates the sum % r=c_0 pi_0(x)+c_1 pi_1(x)+...+c_n pi_n(x) in (monic) Sobolev % orthogonal polynomials and its first s derivatives, where % s<=2. The coefficients c_j are assumed input via the 1x(n+1) % array c. The argument x is allowed to be vector-valued. % function r=clenshaw_sob(n,N,s,x,B,c) if N<0|n<0|n>N, error('N or n out of range'), end if s>2, error('s too large'), end if size(x,2)>1, x=x'; end lx=length(x); if max(size(B)<[N N])>0, error('array B too small'), end if size(c,2)0 for k=n:-1:1 v(:,k)=(x-B(1,k)).*v(:,k+1)+u(:,k+1); if k1 for k=n:-1:1 w(:,k)=(x-B(1,k)).*w(:,k+1); if k>1, w(:,k)=w(:,k)+u(:,k+1); end if k