File: compositions-doc.m2

package info (click to toggle)
macaulay2 1.25.05%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 172,152 kB
  • sloc: cpp: 107,824; ansic: 16,193; javascript: 4,189; makefile: 3,899; lisp: 702; yacc: 604; sh: 476; xml: 177; perl: 114; lex: 65; python: 33
file content (46 lines) | stat: -rw-r--r-- 1,302 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--- author: Lily Silverstein

doc ///
 Key
  compositions
  (compositions, ZZ)
  (compositions, ZZ, ZZ)
 Headline
  list the compositions of an integer
 Usage
  compositions(k, n)
 Inputs
  k:ZZ
   a nonnegative integer, the number of parts in each composition
  n:ZZ
   a nonnegative integer, the sum of each composition (if omitted, assumed to be also $k$)
 Outputs
  :List
   of all ordered lists of {\tt k} nonnegative integers 
   that sum to {\tt n}
 Description
  Example
   compositions(4, 2)
   compositions(2, 4)
  Text
   To find all unordered compositions, we can use @TO sort@ or 
   @TO rsort@ to put each composition into a standard form, then
   use the function @TO unique@ to remove duplicates.
  Example
   unique apply(compositions(4, 10), comp -> rsort comp)
  Text
   In the next example, we use @TO select@ to find all the compositions
   of 18 into 5 parts, with each part greater than or equal to 3.
  Example
   select(compositions(5, 18), comp -> all(comp, c -> c>=3))
  Text
   For partitions of {\tt n} into unordered, {\em strictly positive} parts, 
   use @TO partitions@ instead.
   
   If a negative integer is given for {\tt n}, 
   an empty list is returned. If a negative integer is given 
   for {\tt k}, it will cause an error.
 SeeAlso
  partitions
  subsets
///