fact_dke_jd

PURPOSE ^

SYNOPSIS ^

function n = fact_dke_jd(n)

DESCRIPTION ^

 Factorial function compatible with singles.
 See factorial for more info.

 by J. Decker

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function n = fact_dke_jd(n)
0002 %
0003 % Factorial function compatible with singles.
0004 % See factorial for more info.
0005 %
0006 % by J. Decker
0007 %
0008 N = n(:);
0009 %
0010 if any(fix(N) ~= N) || any(N < 0) || ~isreal(N)
0011   error('MATLAB:factorial:NNegativeInt', ...
0012         'N must be a matrix of non-negative integers.')
0013 end
0014 %
0015 if isa(N,'double'),
0016     %
0017     n(N>170) = 171;
0018     m = max([1; n(:)]);
0019     N = [1 1 cumprod(2:m)];
0020     n(:) = N(n+1);
0021     %
0022 elseif isa(N,'single'),
0023     %
0024     n(N>34) = 35;
0025     m = max([1; n(:)]);
0026     N = [1 1 cumprod(2:m)];
0027     n(:) = N(n+1);
0028     %
0029 else
0030     error('Input must be double or single')
0031 end
0032     
0033 
0034 
0035

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.