Function to create all moi permutations

moi_perms(m, n = 3)

Arguments

m

Total number we are summing to

n

Number of different non-negative integers used. Default = 3

Value

Returns a matrix with n columns, with each row summing to m.

Details

Creates a matrix of the different ways of adding to m with n non-negative integers.

Examples

if (FALSE) { moi_perms(2,3) icer:::moi_perms(m = 2, n = 3) #> [,1] [,2] [,3] #> [1,] 0 0 2 #> [2,] 1 0 1 #> [3,] 2 0 0 #> [4,] 0 1 1 #> [5,] 1 1 0 #> [6,] 0 2 0 }