Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: vector partitions #128

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Stivanification
Copy link

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

Stivanification and others added 3 commits January 5, 2017 17:00
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]]
@Stivanification Stivanification changed the title RFC: vector partitions Draft: vector partitions Dec 25, 2022
@codecov
Copy link

codecov bot commented Dec 26, 2022

Codecov Report

Base: 96.85% // Head: 97.02% // Increases project coverage by +0.16% 🎉

Coverage data is based on head (6245f53) compared to base (d1b633b).
Patch coverage: 100.00% of modified lines in pull request are covered.

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              
Impacted Files Coverage Δ
src/vectorpartitions.jl 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Stivanification Stivanification changed the title Draft: vector partitions RFC: vector partitions Dec 26, 2022
@Stivanification Stivanification marked this pull request as draft December 26, 2022 09:36
@Stivanification Stivanification marked this pull request as ready for review December 26, 2022 09:36

function vector_partitions(vector::Vector{Int64},min=zeros(Integer,length(vector)))

# Creates all vector partitions of "vector" with all parts greater than
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this (and the similar comments in functions below) could be moved above the function as a doc string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants