Code covered by the BSD License  

Highlights from
slatec

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

[x,algam,sgngam]=algams(x,algam,sgngam);
function [x,algam,sgngam]=algams(x,algam,sgngam);
persistent intmlv ; 

if isempty(intmlv), intmlv=0; end;
%***BEGIN PROLOGUE  ALGAMS
%***PURPOSE  Compute the logarithm of the absolute value of the Gamma
%            function.
%***LIBRARY   SLATEC (FNLIB)
%***CATEGORY  C7A
%***TYPE      SINGLE PRECISION (ALGAMS-S, DLGAMS-D)
%***KEYWORDS  ABSOLUTE VALUE OF THE LOGARITHM OF THE GAMMA FUNCTION,
%             FNLIB, SPECIAL FUNCTIONS
%***AUTHOR  Fullerton, W., (LANL)
%***DESCRIPTION
%
% Evaluates the logarithm of the absolute value of the gamma
% function.
%     X           - input argument
%     ALGAM       - result
%     SGNGAM      - is set to the sign of GAMMA(X) and will
%                   be returned at +1.0 or -1.0.
%
%***REFERENCES  (NONE)
%***ROUTINES CALLED  ALNGAM
%***REVISION HISTORY  (YYMMDD)
%   770701  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  ALGAMS
%***FIRST EXECUTABLE STATEMENT  ALGAMS
[algam ,x]=alngam(x);
sgngam = 1.0;
if( x>0.0 )
return;
end;
%
intmlv = rem(-fix(x),2.0) + 0.1;
if( intmlv==0 )
sgngam = -1.0;
end;
%
end
%DECK ALI

Contact us