Open
Conversation
This is a julia port of the sage VectorPartitions function originally written by Amritanshu Prasad (2013).
A vector partition of "vec" is a list of vectors with non-negative integer entries whose sum is "vec". The method vector_partitions creates all vector partitions of "vector" with all parts greater than or equal to "min" in lexicographic order recursively.
INPUT:
- "vec" -- a list of non-negative integers.
EXAMPLES:
If "min" is not specified, then the class of all vector partitions of
"vec" 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]]
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #128 +/- ##
==========================================
+ Coverage 96.85% 97.02% +0.16%
==========================================
Files 7 8 +1
Lines 700 739 +39
==========================================
+ Hits 678 717 +39
Misses 22 22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
natemcintosh
reviewed
Jan 1, 2023
|
|
||
| function vector_partitions(vector::Vector{Int64},min=zeros(Integer,length(vector))) | ||
|
|
||
| # Creates all vector partitions of "vector" with all parts greater than |
Contributor
There was a problem hiding this comment.
Maybe this (and the similar comments in functions below) could be moved above the function as a doc string?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey everybody,
I implemented this functionality for computing vector partitions years ago and submitted a pull request which grew stale. I recently got back to this and in the hope that perhapas someone might find this useful I have cleaned up the code and added some tests. I would be happy to receive any kind of feedback.
Cheers