JuliaMath / Combinatorics.jl

A combinatorics library for Julia
http://juliamath.github.io/Combinatorics.jl/dev/
Other
214 stars 58 forks source link

Compositions #142

Open densmojd opened 11 months ago

densmojd commented 11 months ago

This PR provides functionality for generating compositions, specifically two different types of compositions:

This PR partially addresses #101, although the composition in that case seems to be the union of all compositions of n into k parts (as defined above) over all possible k (k <= n).

The algorithm for weak compositions relies on the relationship between weak compositions and combinations (I think it comes from TAoCP, but I've long since lost the reference) and uses the existing Combinations iterator. The algorithm for compositions relies on the fact that adding one to each element of a weak composition of n into k parts yields a composition of n + k into k parts.

codecov[bot] commented 11 months ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (ac70c46) 96.97% compared to head (3b3446c) 97.13%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #142 +/- ## ========================================== + Coverage 96.97% 97.13% +0.15% ========================================== Files 7 8 +1 Lines 728 767 +39 ========================================== + Hits 706 745 +39 Misses 22 22 ``` | [Files](https://app.codecov.io/gh/JuliaMath/Combinatorics.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath) | Coverage Δ | | |---|---|---| | [src/compositions.jl](https://app.codecov.io/gh/JuliaMath/Combinatorics.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL2NvbXBvc2l0aW9ucy5qbA==) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.