function [cosdgresult,x]=cosdg(x);
cosdgresult=[];
persistent cosdg firstCall n raddeg ; if isempty(firstCall),firstCall=1;end;
if isempty(cosdgresult), cosdgresult=0; end;
if isempty(raddeg), raddeg=0; end;
if isempty(n), n=0; end;
%***BEGIN PROLOGUE COSDG
%***PURPOSE Compute the cosine of an argument in degrees.
%***LIBRARY SLATEC (FNLIB)
%***CATEGORY C4A
%***TYPE SINGLE PRECISION (COSDG-S, DCOSDG-D)
%***KEYWORDS COSINE, DEGREES, ELEMENTARY FUNCTIONS, FNLIB,
% TRIGONOMETRIC
%***AUTHOR Fullerton, W., (LANL)
%***DESCRIPTION
%
% COSDG(X) evaluates the cosine for real X in degrees.
%
%***REFERENCES (NONE)
%***ROUTINES CALLED (NONE)
%***REVISION HISTORY (YYMMDD)
% 770601 DATE WRITTEN
% 890531 Changed all specific intrinsics to generic. (WRB)
% 890531 REVISION DATE from Version 3.2
% 891214 Prologue converted to Version 4.0 format. (BAB)
%***end PROLOGUE COSDG
% JUNE 1977 EDITION. W. FULLERTON, C3, LOS ALAMOS SCIENTIFIC LAB.
if firstCall, raddeg=[.017453292519943296e0]; end;
firstCall=0;
%
%***FIRST EXECUTABLE STATEMENT COSDG
cosdgresult = cos(raddeg.*x);
%
if( rem(x,90.)~=0. )
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',x); evalin('caller',[inputname(1),'=FUntemp;']); end
return;
end;
n = fix(abs(x)./90.0 + 0.5);
n = fix(rem(n,2));
if( n==0 )
cosdgresult = (abs(1.0).*sign(cosdgresult));
end;
if( n==1 )
cosdgresult = 0.0;
end;
%
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',x); evalin('caller',[inputname(1),'=FUntemp;']); end
end
%DECK COSGEN