Code covered by the BSD License  

Highlights from
slatec

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

[cexprlresult,z]=cexprl(z);
function [cexprlresult,z]=cexprl(z);
cexprlresult=[];
persistent alneps first firstCall i nterms r rbnd xln xn ; if isempty(firstCall),firstCall=1;end; 

;
if isempty(alneps), alneps=0; end;
if isempty(r), r=0; end;
if isempty(rbnd), rbnd=0; end;
if isempty(xln), xln=0; end;
if isempty(xn), xn=0; end;
if isempty(i), i=0; end;
if isempty(nterms), nterms=0; end;
%***BEGIN PROLOGUE  CEXPRL
%***PURPOSE  Calculate the relative error exponential (EXP(X)-1)/X.
%***LIBRARY   SLATEC (FNLIB)
%***CATEGORY  C4B
%***TYPE      COMPLEX (EXPREL-S, DEXPRL-D, CEXPRL-C)
%***KEYWORDS  ELEMENTARY FUNCTIONS, EXPONENTIAL, FIRST ORDER, FNLIB
%***AUTHOR  Fullerton, W., (LANL)
%***DESCRIPTION
%
% Evaluate  (EXP(Z)-1)/Z .  For small ABS(Z), we use the Taylor
% series.  We could instead use the expression
%        CEXPRL(Z) = (EXP(X)*EXP(I*Y)-1)/Z
%                  = (X*EXPREL(X) * (1 - 2*SIN(Y/2)**2) - 2*SIN(Y/2)**2
%                                    + I*SIN(Y)*(1+X*EXPREL(X))) / Z
%
%***REFERENCES  (NONE)
%***ROUTINES CALLED  R1MACH
%***REVISION HISTORY  (YYMMDD)
%   770801  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  CEXPRL
if isempty(first), first=false; end;
if firstCall,   first=[true];  end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT  CEXPRL
if( first )
alneps = log(r1mach(3));
xn = 3.72 - 0.3.*alneps;
xln = log((xn+1.0)./1.36);
nterms = fix(xn -(xn.*xln+alneps)./(xln+1.36) + 1.5);
[rbnd ]=r1mach(3);
end;
first = false;
%
r = abs(z);
if( r>0.5 )
cexprlresult =(exp(z)-1.0)./z;
end;
if( r>0.5 )
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',z); evalin('caller',[inputname(1),'=FUntemp;']); end
return;
end;
%
cexprlresult =complex(1.0,0.0);
if( r<rbnd )
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',z); evalin('caller',[inputname(1),'=FUntemp;']); end
return;
end;
%
cexprlresult =complex(0.0,0.0);
for i = 1 : nterms;
cexprlresult = 1.0 + cexprlresult.*z./(nterms+2-i);
end; i = fix(nterms+1);
%
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 CFFTB1

Contact us at files@mathworks.com