function [lun,kprint,ipass]=rqrtst(lun,kprint,ipass);
persistent beta chk coef fatal firstCall i ierr itmp j kontrl nerr root tol work ; if isempty(firstCall),firstCall=1;end;
if isempty(beta), beta=0; end;
if isempty(tol), tol=0; end;
if isempty(work), work=zeros(1,63); end;
if isempty(i), i=0; end;
if isempty(ierr), ierr=0; end;
if isempty(j), j=0; end;
if isempty(kontrl), kontrl=0; end;
if isempty(nerr), nerr=0; end;
if isempty(itmp), itmp=zeros(1,7); end;
if isempty(root), root=zeros(1,7); end;
if isempty(chk), chk=zeros(1,7); end;
if isempty(coef), coef=zeros(1,8); end;
if isempty(fatal), fatal=false; end;
if firstCall, chk=[complex(1.4142135623731,1.4142135623731),complex(1.4142135623731,-1.4142135623731),complex(0.0,2.0),complex(0.0,-2.0),complex(-2.0,0.0),complex(-1.4142135623731,1.4142135623731),complex(-1.4142135623731,-1.4142135623731)]; end;
firstCall=0;
if( kprint>=2 )
writef(lun,['1', '\n ' ,' RPQR79 QUICK CHECK' ' \n']);
end;
%format ('1',/,' RPQR79 QUICK CHECK');
tol = sqrt(r1mach(4));
ipass = 1;
beta = 0.0078125;
for j = 1 : 8;
coef(j) = beta;
beta = 2.0.*beta;
end; j = fix(8+1);
[dumvar1,coef,root,ierr,work]=rpqr79(7,coef,root,ierr,work);
for i = 1 : 7;
itmp(i) = 0;
end; i = fix(7+1);
for i = 1 : 7;
for j = 1 : 7;
if( abs(root(i)-chk(j))<=tol )
itmp(j) = 1;
break;
end;
end;
end;
ipass = 1;
for i = 1 : 7;
ipass = fix(ipass.*itmp(i));
end; i = fix(7+1);
if( kprint>=3 ||(kprint>=2 && ipass==0) )
writef(lun,[ '\n ' ,' CHECK REAL AND IMAGINARY PARTS OF ROOT', '\n ' ,' COEFFICIENTS' ' \n']);
%format [,' CHECK REAL AND IMAGINARY PARTS OF ROOT'/' COEFFICIENTS');
for j=(1):(8), writef(lun,[ '\n ' ,repmat(['%6i',repmat(' ',1,3),repmat('%f',1,1),'%22.14f'] ,1,1) ' \n'],j,coef(j)); end;
%format[(i6,3x,1p,e22.14));
writef(lun,[ '\n ' , '\n ' ,repmat(' ',1,25),'TABLE of ROOTS', '\n ' , '\n ' ,' ROOT REAL PART',repmat(' ',1,12),'IMAG PART', '\n ' ,' NUMBER',repmat(' ',1,8),repmat([' of ZERO ',repmat(' ',1,12)] ,1,2) ' \n']);
%format [/25X,'TABLE of ROOTS'//' ROOT REAL PART',12X,'IMAG PART'/' NUMBER',8X,2(' of ZERO ',12X));
for j=(1):(7), writef(lun,['%6i',repmat(' ',1,3),repmat('%f',1,1),repmat('%22.14f',1,2) ' \n'],j,root(j)); end;
%format(i6,3x,1p,2e22.14);
end;
if( kprint>=2 )
[lun,dumvar2,ipass]=pass(lun,1,ipass);
end;
[kontrl]=xgetf(kontrl);
if( kprint<=2 )
xsetf(0);
else;
xsetf(1);
end;
fatal = false;
xerclr;
if( kprint>=3 )
writef(lun,[ '\n ' , '\n ' ,' TRIGGER 2 ERROR CONDITIONS', '\n ' , '\n ' ' \n']);
end;
%format [/' TRIGGER 2 ERROR CONDITIONS'/];
[dumvar1,coef,root,ierr,work]=rpqr79(0,coef,root,ierr,work);
if( numxer(nerr)~=3 )
fatal = true;
end;
xerclr;
coef(1) = 0.0;
[dumvar1,coef,root,ierr,work]=rpqr79(2,coef,root,ierr,work);
if( numxer(nerr)~=2 )
fatal = true;
end;
xerclr;
[kontrl]=xsetf(kontrl);
if( fatal )
ipass = 0;
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>1 )
writef(lun,[ '\n ' ,' ****RPQR79 PASSED ALL TESTS****' ' \n']);
end;
%format [' ****RPQR79 PASSED ALL TESTS****');
if( ipass==0 && kprint~=0 )
writef(lun,[ '\n ' ,' ****RPQR79 FAILED SOME TESTS***' ' \n']);
end;
%format [' ****RPQR79 FAILED SOME TESTS***');
return;
end %subroutine rqrtst