function [lun,kprint,ipass]=fztest(lun,kprint,ipass);
persistent ae b c fatal iflag kontrl pi r re tol ;
if isempty(iflag), iflag=0; end;
if isempty(kontrl), kontrl=0; end;
if isempty(ae), ae=0; end;
if isempty(b), b=0; end;
if isempty(c), c=0; end;
if isempty(pi), pi=0; end;
if isempty(r), r=0; end;
if isempty(re), re=0; end;
if isempty(tol), tol=0; end;
if isempty(fatal), fatal=false; end;
if( kprint>=2 )
writef(lun,['1', '\n ' ,' FZERO QUICK CHECK' ' \n']);
end;
%format ('1'/' FZERO QUICK CHECK');
ipass = 1;
pi = 4.0e0.*atan(1.0e0);
re = 1.0e-6;
ae = 1.0e-6;
tol = max(1.0e-5,sqrt(r1mach(4)));
b = 0.1e0;
c = 4.0e0;
r = c - b;
[dumvar1,b,c,r,re,ae,iflag]=fzero(@sin,b,c,r,re,ae,iflag);
if( abs(b-pi)<=tol && abs(c-pi)<=tol )
if( kprint>=3 )
writef(lun,[' Accuracy test ','%s', '\n ' ,' Example problem results: (answer = PI), B =','%20.14f',' C =','%20.14f', '\n ' ,' IFLAG =','%2i' ' \n'], 'PASSED' , b , c , iflag);
end;
else;
ipass = 0;
if( kprint>=2 )
writef(lun,[' Accuracy test ','%s', '\n ' ,' Example problem results: (answer = PI), B =','%20.14f',' C =','%20.14f', '\n ' ,' IFLAG =','%2i' ' \n'], 'FAILED' , b , c , iflag);
end;
end;
[kontrl]=xgetf(kontrl);
if( kprint<=2 )
xsetf(0);
else;
xsetf(1);
end;
fatal = false;
xerclr;
if( kprint>=3 )
writef(lun,[ '\n ' ,' IFLAG 3 and 4 tests' ' \n']);
end;
%format [' IFLAG 3 and 4 tests');
b = 1.0e0;
c = 2.0e0;
r = 0.5e0.*(b+c);
b_orig=b; [dumvar1,b,c,dumvar4,re,ae,iflag]=fzero(@tan,b,c,b,re,ae,iflag); b(dumvar4~=b_orig)=dumvar4(dumvar4~=b_orig);
if( iflag~=3 )
ipass = 0;
fatal = true;
if( kprint>=2 )
writef(lun,[ '\n ' ,' IFLAG test FAILED. IFLAG =','%2i',', but should ','have been','%2i' ' \n'], iflag , 2);
end;
end;
b = -3.0e0;
c = -0.1e0;
r = 0.5e0.*(b+c);
[dumvar1,b,c,r,re,ae,iflag]=fzero(@sin,b,c,r,re,ae,iflag);
if( iflag~=4 )
ipass = 0;
fatal = true;
if( kprint>=2 )
writef(lun,[ '\n ' ,' IFLAG test FAILED. IFLAG =','%2i',', but should ','have been','%2i' ' \n'], iflag , 4);
end;
end;
xerclr;
[kontrl]=xsetf(kontrl);
if( fatal )
if( kprint>=2 )
writef(lun,[ '\n ' ,' At least IFLAG test failed' ' \n']);
%format [' At least IFLAG test failed');
end;
elseif( kprint>=3 ) ;
writef(lun,[ '\n ' ,' All IFLAG tests passed' ' \n']);
%format [' All IFLAG tests passed');
end;
if( ipass==1 && kprint>=2 )
writef(lun,[ '\n ' ,' FZERO PASSED ALL TESTS****' ' \n']);
end;
%format [' FZERO PASSED ALL TESTS****');
if( ipass==0 && kprint>=1 )
writef(lun,[ '\n ' ,' FZERO FAILED SOME TESTS***' ' \n']);
end;
%format [' FZERO FAILED SOME TESTS***');
return;
%format (' Accuracy test ',a/' Example problem results: (answer = PI), B =',f20.14,' C =',f20.14/' IFLAG =',i2);
%format [' IFLAG test FAILED. IFLAG =',i2,', but should ','have been',i2);
end %subroutine fztest