Code covered by the BSD License  

Highlights from
slatec

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

[dcosdgresult,x]=dcosdg(x);
function [dcosdgresult,x]=dcosdg(x);
dcosdgresult=[];
persistent firstCall n raddeg ; if isempty(firstCall),firstCall=1;end; 

;
if isempty(n), n=0; end;
%***BEGIN PROLOGUE  DCOSDG
%***PURPOSE  Compute the cosine of an argument in degrees.
%***LIBRARY   SLATEC (FNLIB)
%***CATEGORY  C4A
%***TYPE      doubleprecision (COSDG-S, DCOSDG-D)
%***KEYWORDS  COSINE, DEGREES, ELEMENTARY FUNCTIONS, FNLIB,
%             TRIGONOMETRIC
%***AUTHOR  Fullerton, W., (LANL)
%***DESCRIPTION
%
% DCOSDG(X) calculates the doubleprecision trigonometric cosine
% for doubleprecision argument X in units of 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  DCOSDG
if isempty(raddeg), raddeg=0; end;
if firstCall,   raddeg=[0.017453292519943295769236907684886d0];  end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT  DCOSDG
dcosdgresult = cos(raddeg.*x);
%
if( rem(x,90.0d0)~=0.0d0 )
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.0d0 + 0.5d0);
n = fix(rem(n,2));
if( n==0 )
dcosdgresult = (abs(1.0d0).*sign(dcosdgresult));
end;
if( n==1 )
dcosdgresult = 0.0d0;
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 DCOT

Contact us at files@mathworks.com