combinat::composition
--
k-composition of an integer (deprecated)
combinat::composition
computes a list of all distinct ordered k-tuples
(k_1, ..., k_n)
such that n_1 + ... + n_k = n and
n_i >= 1, i=1..k.
combinat::composition(n,k)
n, k | - | integer |
A list of type DOM_LIST
containing
every computed k-tuple also as a list of type DOM_LIST
. If there
exist no k-tuple the empty list is returned.
combinat::composition
(n, k)
returns an empty list if n<1 or
k<1 or n<k.How can one write 5 as a sum of two other positive integers?
>> combinat::warnDeprecated(FALSE):
combinat::composition(5,2)
[[1, 4], [2, 3], [3, 2], [4, 1]]
The function combinat::composition
is deprecated:
>> old_val:=combinat::warnDeprecated(TRUE):
combinat::composition(5,2);
combinat::warnDeprecated(old_val):
Warning: combinat::composition(n,k) is obsolete. Please use 'combinat::integerVector::list(n,k, MinPart=1)' ins\ tead. [combinat::composition] [[1, 4], [2, 3], [3, 2], [4, 1]]
Here is the recommended replacement:
>> combinat::integerVectors::list(5,2, MinPart=1)
[[4, 1], [3, 2], [2, 3], [1, 4]]
Note that the order is changed.
There is no way to write 2 as the sum of 5 positive integers:
>> combinat::composition(2,5)
[]
Here is the recommended replacement:
>> combinat::integerVectors::list(2,5, MinPart=1)
[]
combinat::composition
does not handle symbolic expressions.
>> combinat::composition(xx,2)
Error: Wrong type of 1. argument (type 'Type::NonNegInt' expec\ ted, got argument 'xx'); during evaluation of 'combinat::composition'
MuPAD Combinat, an open source algebraic combinatorics package