# API reference

## Combinations

Combinatorics.CoolLexCombinationsType
CoolLexCombinations

Produce $(n,k)$-combinations in cool-lex order.

Reference

Ruskey, F., & Williams, A. (2009). The coolest way to generate combinations. Discrete Mathematics, 309(17), 5305-5320.

source
Combinatorics.combinationsMethod
combinations(a, n)

Generate all combinations of n elements from an indexable object a. Because the number of combinations can be very large, this function returns an iterator object. Use collect(combinations(a, n)) to get an array of all combinations.

source
Combinatorics.combinationsMethod
combinations(a)

Generate combinations of the elements of a of all orders. Chaining of order iterators is eager, but the sequence at each order is lazy.

source
Combinatorics.powersetFunction
powerset(a, min=0, max=length(a))

Generate all subsets of an indexable object a including the empty set, with cardinality bounded by min and max. Because the number of subsets can be very large, this function returns an iterator object. Use collect(powerset(a, min, max)) to get an array of all subsets.

source

## Factorials

Combinatorics.derangementMethod
derangement(n)

Compute the number of permutations of n with no fixed points, also known as the subfactorial. An alias subfactorial for this function is provided for convenience.

source

## Multinomials

Combinatorics.multiexponentsMethod
multiexponents(m, n)

Returns the exponents in the multinomial expansion (x₁ + x₂ + ... + xₘ)ⁿ.

For example, the expansion (x₁ + x₂ + x₃)² = x₁² + x₁x₂ + x₁x₃ + ... has the exponents:

julia> collect(multiexponents(3, 2))

6-element Array{Any,1}:
[2, 0, 0]
[1, 1, 0]
[1, 0, 1]
[0, 2, 0]
[0, 1, 1]
[0, 0, 2]
source

## Numbers

Combinatorics.lobbnumMethod
lobbnum(m,n)

Compute the Lobb number L(m,n), or the generalised Catalan number given by $\frac{2m+1}{m+n+1} \binom{2n}{m+n}$. Wikipedia : https://en.wikipedia.org/wiki/Lobb_number

source
Combinatorics.narayanaMethod
narayana(n,k)

Compute the Narayana number N(n,k) given by $\frac{1}{n}\binom{n}{k}\binom{n}{k-1}$ Wikipedia : https://en.wikipedia.org/wiki/Narayana_number

source

## Partitions

Combinatorics.integer_partitionsMethod
integer_partitions(n)

List the partitions of the integer n.

Note

The order of the resulting array is consistent with that produced by the computational discrete algebra software GAP.

source
Combinatorics.partitionsMethod
partitions(s::AbstractVector, m::Int)

Generate all set partitions of the elements of an array s into exactly m subsets, represented as arrays of arrays. Because the number of partitions can be very large, this function returns an iterator object. Use collect(partitions(s, m)) to get an array of all partitions. The number of partitions into m subsets is equal to the Stirling number of the second kind, and can be efficiently computed using length(partitions(s, m)).

source
Combinatorics.partitionsMethod
partitions(s::AbstractVector)

Generate all set partitions of the elements of an array s, represented as arrays of arrays. Because the number of partitions can be very large, this function returns an iterator object. Use collect(partitions(s)) to get an array of all partitions. The number of partitions to generate can be efficiently computed using length(partitions(s)).

source
Combinatorics.partitionsMethod
partitions(n, m)

Generate all arrays of m integers that sum to n. Because the number of partitions can be very large, this function returns an iterator object. Use collect(partitions(n, m)) to get an array of all partitions. The number of partitions to generate can be efficiently computed using length(partitions(n, m)).

source
Combinatorics.partitionsMethod
partitions(n)

Generate all integer arrays that sum to n. Because the number of partitions can be very large, this function returns an iterator object. Use collect(partitions(n)) to get an array of all partitions. The number of partitions to generate can be efficiently computed using length(partitions(n)).

source
Combinatorics.prevprodMethod
prevprod(a::Vector{Int}, x)

Previous integer not greater than x that can be written as $\prod k_i^{p_i}$ for integers $p_1$, $p_2$, etc.

For integers $i_1$, $i_2$, $i_3$, this is equivalent to finding the largest $x$ such that

$i_1^{n_1} i_2^{n_2} i_3^{n_3} \leq x$

for integers $n_1$, $n_2$, $n_3$.

source

## Permutations

Combinatorics.levicivitaMethod
levicivita(p)

Compute the Levi-Civita symbol of a permutation p. Returns 1 if the permutation is even, -1 if it is odd, and 0 otherwise.

The parity is computed by using the fact that a permutation is odd if and only if the number of even-length cycles is odd.

source
Combinatorics.nthpermMethod
nthperm(p)

Return the integer k that generated permutation p. Note that nthperm(nthperm([1:n], k)) == k for 1 <= k <= factorial(n).

source
Combinatorics.permutationsMethod
permutations(a)

Generate all permutations of an indexable object a in lexicographic order. Because the number of permutations can be very large, this function returns an iterator object. Use collect(permutations(a)) to get an array of all permutations.

source

## Young diagrams

Combinatorics.characterMethod
character(λ::Partition, μ::Partition)

Compute the character $\chi^{\lambda(\mu)}$ of the partition μ in the λth irreducible representation ("irrep") of the symmetric group $S_n$.

Implements the Murnaghan-Nakayama algorithm as described in:

Dan Bernstein,
"The computational complexity of rules for the character table of Sn",
Journal of Symbolic Computation, vol. 37 iss. 6 (2004), pp 727-748.
doi:10.1016/j.jsc.2003.11.001
source
Combinatorics.leglengthMethod
leglength(ξ::SkewDiagram)
leglength(λ::Partition, μ::Partition)

Compute the leg length for the given skew diagram.

Note

Strictly speaking, the leg length is defined for rim hooks only, but here we define it for all skew diagrams.

source