Code covered by the BSD License  

Highlights from
slatec

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

[ccotresult,z]=ccot(z);
function [ccotresult,z]=ccot(z);
ccotresult=[];
persistent den firstCall sn2x sqeps x2 y2 ; if isempty(firstCall),firstCall=1;end; 

;
if isempty(den), den=0; end;
if isempty(sn2x), sn2x=0; end;
if isempty(sqeps), sqeps=0; end;
if isempty(x2), x2=0; end;
if isempty(y2), y2=0; end;
%***BEGIN PROLOGUE  CCOT
%***PURPOSE  Compute the cotangent.
%***LIBRARY   SLATEC (FNLIB)
%***CATEGORY  C4A
%***TYPE      COMPLEX (COT-S, DCOT-D, CCOT-C)
%***KEYWORDS  COTANGENT, ELEMENTARY FUNCTIONS, FNLIB, TRIGONOMETRIC
%***AUTHOR  Fullerton, W., (LANL)
%***DESCRIPTION
%
% CCOT(Z) calculates the complex trigonometric cotangent of Z.
%
%***REFERENCES  (NONE)
%***ROUTINES CALLED  R1MACH, XERCLR, XERMSG
%***REVISION HISTORY  (YYMMDD)
%   770401  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)
%   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
%   900326  Removed duplicate information from DESCRIPTION section.
%           (WRB)
%***end PROLOGUE  CCOT
if firstCall,   sqeps=[0.];  end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT  CCOT
if( sqeps==0. )
sqeps = sqrt(r1mach(4));
end;
%
x2 = 2.0.*real(z);
y2 = 2.0.*imag(z);
%
sn2x = sin(x2);
xerclr;
%
den = cosh(y2) - cos(x2);
if( den==0. )
xermsg('SLATEC','CCOT','COT IS SINGULAR FOR INPUT Z (X IS 0 OR PI AND Y IS 0)',2,2);
end;
%
if( abs(den)<=max(abs(x2),1.).*sqeps )
xerclr;
xermsg('SLATEC','CCOT',['ANSWER LT HALF PRECISION, ABS(X) TOO BIG OR X TOO NEAR ','0 OR PI'],1,1);
end;
%
ccotresult = complex(sn2x./den,-sinh(y2)./den);
%
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',z); evalin('caller',[inputname(1),'=FUntemp;']); end
end
%DECK CDCDOT

Contact us