Multipartitions

JuLie.MultipartitionType
Multipartition{T} <: AbstractArray{Partition{T},1}

Multipartitions are generalizations of partitions. An r-component multipartition of an integer n is an r-tuple of partitions λ¹, λ², …, λʳ where each λⁱ is a partition of some integer nᵢ ≥ 0 and the nᵢ sum to n.

Multipartitions are implemented as a subtype of 1-dimensional arrays of partitions. You can use smaller integer types to increase performance.

Examples

julia> P=Multipartition( [[2,1], [], [3,2,1]] )
Partition{Int64}[[2, 1], [], [3, 2, 1]]
julia> sum(P)
9
julia> P[2]
Int64[]
julia> P=Multipartition( Array{Int8,1}[[2,1], [], [3,2,1]] )
Partition{Int8}[[2, 1], [], [3, 2, 1]]

References

  1. Wikipedia, Multipartition
source
JuLie.multipartitionsFunction
multipartitions(n::T, r::Integer) where T<:Integer

A list of all r-component multipartitions of n. The algorithm is recursive and based on partitions(::Integer).

Example

julia> multipartitions(2,2)
5-element Vector{Multipartition{Int64}}:
 Partition{Int64}[[], [2]]
 Partition{Int64}[[], [1, 1]]
 Partition{Int64}[[1], [1]]
 Partition{Int64}[[2], []]
 Partition{Int64}[[1, 1], []]
source

Operations

Base.sumMethod
sum(P::Multipartition{T}) where T<:Integer

If P is a multipartition of the integer n, this function returns n.

source