Skip to content

vlt.math.group_enumeration

  GROUP_ENUMERATION - enumerate combinations of groups

  [G, MAX_N] = vlt.math.group_enumeration(M, N)

  Identifies members of multiple groups with a single number.
  For example, suppose we have a group of 3, a group of 2, and another
  group of 2. We want to enumerate all ways in which one member of all 3 groups can be
  combined. We assign [1 1 1] the number 1, [1 1 2] the number 2, [1 2 1] the number 3,
  and so on.

  M is a vector with the number of members of each group. N is the group enumeration
  number to select. G is the group selection for group enumeration N, and MAX_N is
  the maximum number of group enumerations possible. (Same as PROD(M).)

  Example: 
    m = [ 1 3 1]; % 3 digit number, second digit can be 1, 2, or 3; others all 1
    n = 2;
    [g,max_n] = vlt.math.count_irregular_base(m,n,2);
    % g is [1 2 1]; max_n = 3