Combinatorics.jl
Combinatorics.jl copied to clipboard
RFC: Add vector partitions functionality
This is a julia port of the sage VectorPartitions function originally written by Amritanshu Prasad (2013).
A vector partition of "vector" is a list of vectors with non-negative integer entries whose sum is "vector". The method vector_partitions creates all vector partitions of "vector" with all parts greater than or equal to "min" in lexicographic order recursively. The function expects an Int64-Array "vector" as first argument and an optional Int64-Array "min" as second argument.
If "min" is not specified, then the class of all vector partitions of "vector" is created:
julia> vector_partitions([2, 2])
9-element Array{Any,1}:
Array{Int64,1}[[1,0],[1,0],[0,1],[0,1]]
Array{Int64,1}[[2,0],[0,1],[0,1]]
Array{Int64,1}[[1,1],[1,0],[0,1]]
Array{Int64,1}[[2,1],[0,1]]
Array{Int64,1}[[1,0],[1,0],[0,2]]
Array{Int64,1}[[2,0],[0,2]]
Array{Int64,1}[[1,2],[1,0]]
Array{Int64,1}[[1,1],[1,1]]
Array{Int64,1}[[2,2]]
If "min" is specified, then the array lists those vector partitions whose parts are all greater than or equal to "min" in lexicographic order:
julia> vector_partitions([2,2],[1,0])
3-element Array{Any,1}:
Array{Int64,1}[[1,2],[1,0]]
Array{Int64,1}[[1,1],[1,1]]
Array{Int64,1}[[2,2]]
Codecov Report
Merging #43 into master will decrease coverage by
-5.4%
. The diff coverage is0%
.
@@ Coverage Diff @@
## master #43 +/- ##
=========================================
- Coverage 96.96% 91.57% -5.4%
=========================================
Files 6 7 +1
Lines 594 629 +35
=========================================
Hits 576 576
- Misses 18 53 +35
Impacted Files | Coverage Δ | |
---|---|---|
src/vector_partitions.jl | 0% <ø> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update a3a2a05...19ef327. Read the comment docs.
Hm I seem to get code coverage of 0.0 which doesn't seem right at all...
I am going through stalled pull requests of this repo. If you have time and interest to update this, I'm going to review and merge.