The JSR toolbox
10 Oct 2011
05 Feb 2014)
Gathers and compares the best methods for the joint spectral radius computation
function c = nck(n, k)
%NCK Binomial coefficient or all combinations.
% NCK(N,K) where N and K are non-negative integers returns N!/K!(N-K)!.
% This is the number of combinations of N things taken K at a time.
% When a coefficient is large, the result is only accurate to 15 digits
% for double-precision inputs, or 8 digits for single-precision inputs.
% Class support for inputs N,K,V:
% float: double, single
% See also PERMS.
% Copyright 1984-2006 The MathWorks, Inc.
% $Revision: 188.8.131.52 $ $Date: 2006/10/02 16:33:01 $
if k > n/2,
k = n-k;
if k <= 1,
c = n^k;
nums = (n-k+1):n;
dens = 1:k;
nums = nums./dens;
c = round(prod(nums));