Code covered by the BSD License  

Highlights from
slatec

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

[besk0result,x]=besk0(x);
function [besk0result,x]=besk0(x);
besk0result=[];
persistent besk0 bk0cs first firstCall ntk0 xmax xmaxt xsml y ; if isempty(firstCall),firstCall=1;end; 

if isempty(besk0result), besk0result=0; end;
if isempty(bk0cs), bk0cs=zeros(1,11); end;
if isempty(xmax), xmax=0; end;
if isempty(xmaxt), xmaxt=0; end;
if isempty(xsml), xsml=0; end;
if isempty(y), y=0; end;
if isempty(ntk0), ntk0=0; end;
%***BEGIN PROLOGUE  BESK0
%***PURPOSE  Compute the modified (hyperbolic) Bessel function of the
%            third kind of order zero.
%***LIBRARY   SLATEC (FNLIB)
%***CATEGORY  C10B1
%***TYPE      SINGLE PRECISION (BESK0-S, DBESK0-D)
%***KEYWORDS  FNLIB, HYPERBOLIC BESSEL FUNCTION,
%             MODIFIED BESSEL FUNCTION, ORDER ZERO, SPECIAL FUNCTIONS,
%             THIRD KIND
%***AUTHOR  Fullerton, W., (LANL)
%***DESCRIPTION
%
% BESK0(X) calculates the modified (hyperbolic) Bessel function
% of the third kind of order zero for real argument X .GT. 0.0.
%
% Series for BK0        on the interval  0.          to  4.00000D+00
%                                        with weighted error   3.57E-19
%                                         log weighted error  18.45
%                               significant figures required  17.99
%                                    decimal places required  18.97
%
%***REFERENCES  (NONE)
%***ROUTINES CALLED  BESI0, BESK0E, CSEVL, INITS, R1MACH, 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  BESK0
if isempty(first), first=false; end;
if firstCall,   bk0cs(1)=[-.03532739323390276872e0];  end;
if firstCall,   bk0cs(2)=[.3442898999246284869e0];  end;
if firstCall,   bk0cs(3)=[.03597993651536150163e0];  end;
if firstCall,   bk0cs(4)=[.00126461541144692592e0];  end;
if firstCall,   bk0cs(5)=[.00002286212103119451e0];  end;
if firstCall,   bk0cs(6)=[.00000025347910790261e0];  end;
if firstCall,   bk0cs(7)=[.00000000190451637722e0];  end;
if firstCall,   bk0cs(8)=[.00000000001034969525e0];  end;
if firstCall,   bk0cs(9)=[.00000000000004259816e0];  end;
if firstCall,   bk0cs(10)=[.00000000000000013744e0];  end;
if firstCall,   bk0cs(11)=[.00000000000000000035e0];  end;
if firstCall,   first=[true];  end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT  BESK0
if( first )
[ntk0 ,bk0cs]=inits(bk0cs,11,0.1.*r1mach(3));
xsml = sqrt(4.0.*r1mach(3));
xmaxt = -log(r1mach(1));
xmax = xmaxt - 0.5.*xmaxt.*log(xmaxt)./(xmaxt+0.5) - 0.01;
end;
first = false;
%
if( x<=0. )
xermsg('SLATEC','BESK0','X IS ZERO OR NEGATIVE',2,2);
end;
if( x>2. )
%
besk0result = 0.;
if( x>xmax )
xermsg('SLATEC','BESK0','X SO BIG K0 UNDERFLOWS',1,1);
end;
if( x>xmax )
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;
%
besk0result = exp(-x).*besk0e(x);
else;
%
y = 0.;
if( x>xsml )
y = x.*x;
end;
besk0result = -log(0.5.*x).*besi0(x) - .25 + csevl(.5.*y-1.,bk0cs,ntk0);
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;
%
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 BESK1E

Contact us at files@mathworks.com