High Performance Tools for Combinatorics and Computational Mathematics
Overview
Provides optimized functions and flexible iterators implemented in C++ for solving problems in combinatorics and computational mathematics. Handles various combinatorial objects including combinations, permutations, integer partitions and compositions, Cartesian products, unordered Cartesian products, and partition of groups. Utilizes the RMatrix class from 'RcppParallel' for thread safety. The combination and permutation functions contain constraint parameters that allow for generation of all results of a vector meeting specific criteria (e.g. finding all combinations such that the sum is between two bounds). Capable of ranking/unranking combinatorial objects efficiently (e.g. retrieve only the nth lexicographical result) which sets up nicely for parallelization as well as random sampling. Gmp support permits exploration where the total number of results is large (e.g. comboSample(10000, 500, n = 4)). Additionally, there are several high performance number theoretic functions that are useful for problems common in computational mathematics. Some of these functions make use of the fast integer division library 'libdivide'. The primeSieve function is based on the segmented sieve of Eratosthenes implementation by Kim Walisch. It is also efficient for large numbers by using the cache friendly improvements originally developed by Tomás Oliveira. Finally, there is a prime counting function that implements Legendre's formula based on the work of Kim Walisch.
New Features
- Added exact dynamic-programming counting for multiset partitions and compositions, including weak compositions and non-weak compositions with zero padding. Large counts use GMP-backed
bigzarithmetic where needed.
Bug Fixes
- Fixed overflow in large multiset permutation counts. For example,
permuteCount(2, 2000, freqs = c(1000, 1000))now returns the correctbigzresult (Issue #72, PR #74). - Fixed
FUNbeing ignored for factor inputs incomboGeneral()andpermuteGeneral(). Factors passed toFUNretain their levels and class, including ordered-factor status (Issue #71, PR #75). - Fixed incomplete or unsupported generation of certain multiset compositions with positive input values. When the minimum input value maps internally to zero, it is now correctly treated as an actual part rather than zero padding. This also fixes related iterator, random-access, ranking, and sampling behavior.
Additional Bug Fixes
The following five fixes are covered by Issue #70 and PR #73:
- Fixed product constraints involving negative values: explicitly supplying
lower = 1now correctly restricts testing to the requested candidate range. Withoutlower, generation searches for the requested number of matching results and remains serial, even when multiple threads are requested. - Fixed parallel iterator batches starting from an incorrect position when
constraintFunis supplied without filtering. - Corrected iterator positioning after oversized batch requests and exhaustion reporting for constrained iterators.
- Multi-index access to partition and composition iterators no longer alters subsequent traversal.
Show all changes in 2.10.2Hide the rest of the changes in 2.10.2
- Improved handling of non-finite count estimates by switching to arbitrary-precision arithmetic. Invalid non-finite numeric arguments are rejected before conversion.
Improvements
- Updated
partition_typelabels returned by design functions to use clearer names, such asDistinctNoZeroandCompRepZero. Multiset composition designs now distinguish weak and zero-padded cases. - Multiset partition generation now validates
upperagainst the computed result count. - Improved errors for unsupported partition and composition ranking or sampling, and for cases with no solution.
- Clarified threading restrictions for special constraints and documented calling
startOver()before reusing an iterator after a generation error. - Improved handling of unsupported multiset compositions. Counting remains available where supported, while generation now provides clearer errors and guidance about permutation-based alternatives.
- Enhanced
compositionsDesign()andpartitionsDesign()diagnostics. Unknown counts are now reported asNArather than preventing design inspection. Design output also includes additional classification metadata, improved GMP count formatting, andNAfor unavailable equation checks.
Performance
- Replaced enumeration-based multiset partition and composition counting with dynamic programming.
- Improved GMP-backed multiset counting with specialized partition and composition implementations that reduce intermediate allocation and arbitrary-precision arithmetic overhead.
- Reduced intermediate allocation and copying when generating multiset partitions and sum-constrained multiset permutations.
From inst/NEWS.Rd in the release
Install
Health
- OK13 OK2026-09-08
- ERROR12 OK, 1 ERROR2026-09-07
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-05-10
Show 3 earlier changesHide 3 earlier changes
- WARNING12 OK, 1 WARNING2026-05-09
- OK12 OK2026-04-25
- NOTE11 OK, 3 NOTE2026-03-10
Documentation
- Help pages
- 35includes a package overview page
- Examples that run
- 100%34 run in a plain check
- Exported functions with examples
- 100%
- Documented parameters
- 100%
- Return-value docs
- 100%
- Help pages citing references
- 57%
- Attacking Problems Related to the Subset Sum Problem
- Cartesian Products and Partitions of Groups
- Combination and Permutation Basics
- Combinatorial Iterators in RcppAlgos
- Combinatorial Sampling and Ranking
- Computational Mathematics Overview
- Constraint-Driven Combinatorial Enumeration
- High Performance Benchmarks
- Integer Compositions
- Integer Partitions
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 22
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
Commits over time
7 development-tooling and community-health practices detected across 4 families in the upstream repository
Checks run against github.com/jwood000/rcppalgos on 2026-10-11.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-10-06 · The repository has a site deploy workflow
pkgdown site last built 2026-10-06, before release 2.10.2 (2026-10-17)
Dependencies
Installing RcppAlgos adds 2 packages (1 with compiled code, 461 KB of source tarballs). Heaviest: cpp11 298 KB, gmp 163 KB.
Code & Tests
People & History
Pick two releases to compare their code metrics.
- 2.10.2Latest2026-10-17 · current release · diff ↗ ·
listed once in CRAN's queue
Seen in one reading of CRAN's incoming queue, at 2026-10-17 21:55 UTC, so it stayed less than the time between readings. - 2.10.12026-06-08 · diff ↗
- RR 4.6.0 released · 2026-04-24
- 2.10.02026-03-08 · diff ↗
- 2.9.52026-01-29 · diff ↗
- RR 4.5.0 released · 2025-04-11
- 2.9.32025-02-03 · diff ↗
- 2.9.1
- 2.8.52024-10-11 · diff ↗
- RR 4.4.0 released · 2024-04-24
- 2.8.32023-12-10 · diff ↗
- 2.8.2
- 2.8.12023-08-14 · diff ↗
- 2.8.02023-07-11 · diff ↗
- RR 4.3.0 released · 2023-04-21
- 2.7.22023-02-11 · diff ↗
Show 34 earlier eventsHide 34 earlier events
- 2.7.12023-02-06 · diff ↗
- 2.6.02022-08-15 · diff ↗ ·
added 8 exports
compositionsGeneral, compositionsCount, compositionsSample, comboRank, permuteRank, partitionsRank, compositionsRank, compositionsIter - RR 4.2.0 released · 2022-04-22
- 2.5.32022-03-31 · diff ↗
- 2.5.02022-03-16 · diff ↗ ·
added 4 exports
partitionsGeneral, partitionsCount, partitionsSample, partitionsIter - 2.4.3
- RR 4.1.0 released · 2021-05-18
- RR 4.0.0 released · 2020-04-24
- 2.4.1
- 2.3.62020-01-29 · diff ↗
- 2.3.5
- 2.3.42019-07-03 · diff ↗
- 2.3.32019-06-30 · diff ↗
- RR 3.6.0 released · 2019-04-26
- 2.3.22019-04-14 · diff ↗
- 2.3.12019-03-21 · diff ↗
- 2.3.0
- 2.2.02018-09-15 · diff ↗
- 2.1.02018-09-11 · diff ↗
- 2.0.32018-06-30 · diff ↗
- 2.0.22018-06-14 · diff ↗
- 2.0.1
- RR 3.5.0 released · 2018-04-23
- 1.0.12018-03-10 · diff ↗
- 1.0.02018-03-07 · diff ↗ ·
removed 2 exports
primeFactorizationList, divisorsListadded 6 exports
primeFactorizeSieve, divisorsSieve, primeFactorize, divisorsRcpp, isPrimeRcpp, primeCount - 0.2.52018-01-04 · diff ↗
- 0.2.42017-12-18 · diff ↗
- 0.2.22017-12-15 · diff ↗
- 0.2.12017-11-30 · diff ↗
- 0.2.0
- 0.1.22017-11-03 · diff ↗
- 0.1.12017-11-03 · diff ↗
- 0.1.02017-10-26
- RR 3.4.0 released · 2017-04-21
Package metadata
- First published
- 2017-10-26
- Total releases
- 40 / 9 yrs
- License
- GPL (>= 2) OSI
- Download size
- 1.6 MB
Cite
Cite this package
Run in R for the authors' entry:
citation("RcppAlgos")The package provides a citation file, so citation() returns the authors' own entry.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-18, which the citation names so these numbers can be found later. More on citing and the projects behind them.