Code covered by the BSD License  

Highlights from
slatec

from slatec by Ben Barrowes
The slatec library converted into matlab functions.

[lun,kprint,ipass]=pntchk(lun,kprint,ipass);
function [lun,kprint,ipass]=pntchk(lun,kprint,ipass);
persistent c d dchk fatal firstCall i ierr kontrl n nerr tol w x xchk y yf ; if isempty(firstCall),firstCall=1;end; 

if isempty(tol), tol=0; end;
if isempty(yf), yf=0; end;
if isempty(i), i=0; end;
if isempty(ierr), ierr=0; end;
if isempty(kontrl), kontrl=0; end;
if isempty(n), n=0; end;
if isempty(nerr), nerr=0; end;
if isempty(fatal), fatal=false; end;
if isempty(c), c=zeros(1,6); end;
if isempty(d), d=zeros(1,6); end;
if isempty(dchk), dchk=zeros(1,6); end;
if isempty(w), w=zeros(1,12); end;
if isempty(x), x=zeros(1,6); end;
if isempty(xchk), xchk=zeros(1,6); end;
if isempty(y), y=zeros(1,6); end;
if firstCall,   x=[1.0e0,2.0e0,3.0e0,-1.0e0,-2.0e0,-3.0e0];  end;
if firstCall,   y=[0.0e0,9.0e0,64.0e0,0.0e0,9.0e0,64.0e0];  end;
if firstCall,   xchk=[1.0e0,0.0e0,-2.0e0,0.0e0,1.0e0,0.0e0];  end;
if firstCall,   dchk=[1.0e0,0.0e0,-4.0e0,0.0e0,24.0e0,0.0e0];  end;
firstCall=0;
if( kprint>=2 )
writef(lun,['1', '\n ' ,' Test POLINT, POLCOF and POLYVL' ' \n']);
end;
%format ('1'/' Test POLINT, POLCOF and POLYVL');
tol = sqrt(r1mach(4));
ipass = 1;
n = 6;
[n,x,y,c]=polint(n,x,y,c);
[dumvar1,n,x,c,d,w]=polcof(0.0e0,n,x,c,d,w);
fatal = false;
for i = 1 : n;
if( abs(d(i)-xchk(i))>tol )
ipass = 0;
fatal = true;
end;
end; i = fix(n+1);
if( fatal )
if( kprint>=2 )
for i=(1):(n),  writef(lun,[ '\n ' ,'POLCOF ','%s',' test', '\n ' ,' Taylor coefficients for the quintic should be', '\n ' ,repmat(' ',1,6),'1.000',repmat(' ',1,5),'0.000',repmat(' ',1,4),'-2.000',repmat(' ',1,5),'0.000',repmat(' ',1,5),'1.000',repmat(' ',1,5),'0.000', '\n ' ,' Taylor coefficients from POLCOF are', '\n ' ,repmat(' ',1,1),repmat('%10.3f',1,6), '\n '  ' \n'], 'FAILED' , d(i)); end;
end;
else;
if( kprint>=3 )
for i=(1):(n),  writef(lun,[ '\n ' ,'POLCOF ','%s',' test', '\n ' ,' Taylor coefficients for the quintic should be', '\n ' ,repmat(' ',1,6),'1.000',repmat(' ',1,5),'0.000',repmat(' ',1,4),'-2.000',repmat(' ',1,5),'0.000',repmat(' ',1,5),'1.000',repmat(' ',1,5),'0.000', '\n ' ,' Taylor coefficients from POLCOF are', '\n ' ,repmat(' ',1,1),repmat('%10.3f',1,6), '\n '  ' \n'], 'PASSED' , d(i)); end;
end;
end;
[dumvar1,dumvar2,yf,d,n,x,c,w,ierr]=polyvl(5,0.0e0,yf,d,n,x,c,w,ierr);
if( abs(dchk(1)-yf)<=tol )
if( kprint>=3 )
for i=(1):(5),  writef(lun,[' Derivative test ','%s', '\n ' ,' The derivatives of the polynomial at zero as ','computed by POLYVL are', '\n ' ,repmat(' ',1,1),repmat('%10.3f',1,6), '\n '  ' \n'], 'PASSED' , yf , d(i)); end;
end;
else;
ipass = 0;
if( kprint>=2 )
for i=(1):(5),  writef(lun,[' Derivative test ','%s', '\n ' ,' The derivatives of the polynomial at zero as ','computed by POLYVL are', '\n ' ,repmat(' ',1,1),repmat('%10.3f',1,6), '\n '  ' \n'], 'FAILED' , yf , d(i)); end;
end;
end;
fatal = false;
for i = 1 : 5;
if( abs(dchk(i+1)-d(i))>tol )
ipass = 0;
fatal = true;
end;
end; i = fix(5+1);
[kontrl]=xgetf(kontrl);
if( kprint<=2 )
xsetf(0);
else;
xsetf(1);
end;
fatal = false;
xerclr;
if( kprint>=3 )
writef(lun,[ '\n ' ,' 2 Error messages expected' ' \n']);
end;
%format [' 2 Error messages expected');
[dumvar1,x,y,c]=polint(0,x,y,c);
if( numxer(nerr)~=2 )
ipass = 0;
fatal = true;
end;
xerclr;
x(1) = -1.0e0;
[n,x,y,c]=polint(n,x,y,c);
if( numxer(nerr)~=2 )
ipass = 0;
fatal = true;
end;
xerclr;
[kontrl]=xsetf(kontrl);
if( fatal )
if( kprint>=2 )
writef(lun,[ '\n ' ,' AT LEAST ONE INCORRECT ARGUMENT TEST FAILED' ' \n']);
%format [' AT LEAST ONE INCORRECT ARGUMENT TEST FAILED');
end;
elseif( kprint>=3 ) ;
writef(lun,[ '\n ' ,' ALL INCORRECT ARGUMENT TESTS PASSED' ' \n']);
%format [' ALL INCORRECT ARGUMENT TESTS PASSED');
end;
if( ipass==1 && kprint>=2 )
writef(lun,[ '\n ' ,' *POLINT PASSED ALL TESTS****' ' \n']);
end;
%format [' *POLINT PASSED ALL TESTS****');
if( ipass==0 && kprint>=1 )
writef(lun,[ '\n ' ,' POLINT FAILED SOME TESTS****' ' \n']);
end;
%format [' POLINT FAILED SOME TESTS****');
return;
%format ['POLCOF ',a,' test'/' Taylor coefficients for the quintic should be'/6X,'1.000',5X,'0.000',4X,'-2.000',5X,'0.000',5X,'1.000',5X,'0.000'/' Taylor coefficients from POLCOF are'/1X,6F10.3];
%format (' Derivative test ',a/' The derivatives of the polynomial at zero as ','computed by POLYVL are'/1X,6F10.3];
end %subroutine pntchk

Contact us at files@mathworks.com