Package: RcppAlgos 2.10.1

Joseph Wood

RcppAlgos: High Performance Tools for Combinatorics and Computational Mathematics

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.

Authors:Joseph Wood [aut, cre]

RcppAlgos_2.10.1.tar.gz
RcppAlgos_2.10.1.zip(r-4.7)RcppAlgos_2.10.1.zip(r-4.6)RcppAlgos_2.10.1.zip(r-4.5)
RcppAlgos_2.10.1.tgz(r-4.6-x86_64)RcppAlgos_2.10.1.tgz(r-4.6-arm64)RcppAlgos_2.10.1.tgz(r-4.5-x86_64)RcppAlgos_2.10.1.tgz(r-4.5-arm64)
RcppAlgos_2.10.1.tar.gz(r-4.7-arm64)RcppAlgos_2.10.1.tar.gz(r-4.7-x86_64)RcppAlgos_2.10.1.tar.gz(r-4.6-arm64)RcppAlgos_2.10.1.tar.gz(r-4.6-x86_64)
RcppAlgos_2.10.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
RcppAlgos/json (API)

# Install 'RcppAlgos' in R:
install.packages('RcppAlgos', repos = c('https://fastverse.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/jwood000/rcppalgos/issues

Pkgdown/docs site:https://jwood000.github.io

Uses libs:
  • gmp– Multiprecision arithmetic library
  • c++– GNU Standard C++ Library v3

On CRAN:

Conda:

combinationscombinatoricsfactorizationnumber-theoryparallelpermutationprime-factorizationsprimesievegmpcpp

10.75 score 49 stars 18 packages 325 scripts 1.3k downloads 39 exports 2 dependencies

Last updated from:7660dd7828. Checks:13 OK. Indexed: no.

TargetResultTimeFilesSyslog
linux-devel-arm64OK409
linux-devel-x86_64OK364
source / vignettesOK426
linux-release-arm64OK341
linux-release-x86_64OK375
macos-release-arm64OK243
macos-release-x86_64OK878
macos-oldrel-arm64OK239
macos-oldrel-x86_64OK519
windows-develOK478
windows-releaseOK476
windows-oldrelOK464
wasm-releaseOK242

Exports:comboCountcomboGeneralcomboGridcomboGroupscomboGroupsCountcomboGroupsItercomboGroupsSamplecomboItercomboRankcomboSamplecompositionsCountcompositionsGeneralcompositionsItercompositionsRankcompositionsSampledivisorsRcppdivisorsSieveeulerPhiSieveexpandGridexpandGridCountexpandGridIterexpandGridSampleisPrimeRcppnumDivisorSievepartitionsCountpartitionsGeneralpartitionsIterpartitionsRankpartitionsSamplepermuteCountpermuteGeneralpermuteIterpermuteRankpermuteSampleprimeCountprimeFactorizeprimeFactorizeSieveprimeSievestdThreadMax

Dependencies:cpp11gmp

Cartesian Products and Partitions of Groups
expandGrid | Matrix vs Data.Frame Output | Always Return data.frame | Familiar RcppAlgos API Components | expandGridSample | Powerful Iterators with expandGridIter | Cartesian Product where Order does not Matter | In the Wild | Partitions of Groups with comboGroups | Partitions of Groups of Varying Sizes | Relevant Posts on Stackoverflow as well as OEIS.

Last update: 2026-06-07
Started: 2022-03-15

Attacking Problems Related to the Subset Sum Problem
Building on Integer Partitions | Working with Negative Numbers | Partitions with no Restrictions | Taming Floating Point Numbers | prod and mean | Using Iterators

Last update: 2026-06-07
Started: 2020-01-25

Combination and Permutation Basics
Introducing comboGeneral and permuteGeneral | Combinations/Permutations with Repetition | Working with Multisets | Enter freqs | Parallel Computing | Using arguments lower and upper | Generating Results Beyond .Machine$integer.max | GMP Support | User Defined Functions | Using FUN.VALUE | Passing additional arguments with ... | S3 methods

Last update: 2026-06-07
Started: 2020-01-18

Combinatorial Iterators in RcppAlgos
Iterating over Combinations and Permutations | Bidirectional Iterators | Retrieving More than One Result at a Time | Random Access Iterator | User Defined Functions | Transition from Rcpp Modules to S4 + External Pointers | Access Efficiency in 2.5.0+ | Version 2.4.3 Using Rcpp | Version 2.10.1 (No Rcpp) | Caching Results w/ 2.4.3 | Caching Results w/ 2.10.1 | Access Efficiency Conclusions | Iterating over Partitions and Compositions of a Number | Iterating over Constrained Combinations/Permutations | Iterating over Partitions of Groups

Last update: 2026-06-07
Started: 2020-04-17

Combinatorial Sampling and Ranking
Sampling | Base R | RcppAlgos Solutions | comboSample and permuteSample | Samples of Results with Repetition | Specific Results with sampleVec | Using namedSample | Parallel Computing and GMP Support | Efficiency | User Defined Functions | partitionsSample | compositionsSample | compositionSample with Specific target | compositionSample with Distinct Parts | Unranking Distinct Parts | Sampling Partitions of Groups with comboGroupsSample | Ranking | Rank Multiple Inputs | comboRank | permuteRank | partitionsRank | compositionsRank

Last update: 2026-06-07
Started: 2020-01-18

Computational Mathematics Overview
primeSieve | Larger primes | primeCount | Other Sieving Functions | Vectorized Functions

Last update: 2026-06-07
Started: 2020-01-18

Constraints in RcppAlgos: Constraint-Driven Combinatorial Enumeration
Related articles | Constraint Functions | Faster than rowSums and rowMeans | Comparison Operators and limitConstraints | One Comparison Operator | Two Comparison Operators | Using tolerance | Output Order with permuteGeneral | Integer Partitions & Compositions | Safely Interrupt Execution with cpp11::check_user_interrupt | Note about Interrupting Execution

Last update: 2026-06-07
Started: 2020-01-20

High Performance Benchmarks
Setup Information | Combinations | Combinations - Distinct | Combinations - Repetition | Combinations - Multisets | Permutations | Permutations - Distinct | Permutations - Repetition | Permutations - Multisets | Partitions | Partitions - Distinct | All Distinct Partitions | Restricted Distinct Partitions | Partitions - Repetition | All Partitions | Restricted Partitions | Partitions - Multisets | Compositions | Compositions - Repetition | All Compositions (Small case) | All Compositions (Larger case) | Compositions of Specific Length | Specialized Composition Benchmarks | Compositions with Specific target | Compositions with Distinct Parts | Compositions with Distinct Parts & Specific target | Iterators

Last update: 2026-06-07
Started: 2020-02-15

Integer Compositions in RcppAlgos
Integer Compositions | Standard Compositions | Case 1: All Compositions of N | Case 2: Compositions of N of Length m | Distinct Compositions | Case 3: Compositions of N into Distinct Parts | Verifying Distinct Compositions via Partitions (Brute Force Construction) | Case 4: Integer Compositions of N into Parts of Varying Multiplicity | Generating Compositions with permuteGeneral() | The Role of target | Efficiency Generating Partitions and Compositions

Last update: 2026-06-07
Started: 2026-03-07

Integer Partitions in RcppAlgos
Integer Partitions | Standard Partitions | Case 1: All Integer Partitions of N | Case 2: Integer Partitions of N of Length m | Distinct Partitions | Case 3: Integer Partitions of N into Distinct Parts | Using freqs to Refine Length | Euler’s Theorem in Action (Odd Parts and Distinct Parts) | Caveats Using freqs | Partitions of Multisets | Case 4: Integer Partitions of N into Parts of Varying Multiplicity | Using the table S3 Method | The Role of target | Efficiency Generating Partitions

Last update: 2026-06-07
Started: 2026-03-07

Readme and manuals

Help Manual

Help pageTopics
High Performance Tools for Combinatorics and Computational MathematicsRcppAlgos-package RcppAlgos
S4-class for Exposing C++ Cartesian Class$,Cartesian-method Cartesian-class
S4-classes for Exposing C++ Combinatorial Classes$,Combo-method $,ComboApply-method $,ComboRes-method Combo-class ComboApply-class ComboRes-class
Number of combinations/permutationscomboCount comboCount.default comboCount.list comboCount.table permuteCount permuteCount.default permuteCount.list permuteCount.table
Generate Combinations and Permutations of a Vector with/without ConstraintscomboGeneral comboGeneral.default comboGeneral.factor comboGeneral.integer comboGeneral.list comboGeneral.logical comboGeneral.numeric comboGeneral.table permuteGeneral permuteGeneral.default permuteGeneral.factor permuteGeneral.integer permuteGeneral.list permuteGeneral.logical permuteGeneral.numeric permuteGeneral.table
Unordered Cartesian ProductcomboGrid
Partition a Vector into GroupscomboGroups
S4-class for Exposing C++ ComboGroups Class$,ComboGroups-method ComboGroups-class
Number of Partitions of a Vector into GroupscomboGroupsCount
comboGroups IteratorcomboGroupsIter
Sample Partitions of a Vector into GroupscomboGroupsSample
Combination and Permutation IteratorcomboIter comboIter.default comboIter.factor comboIter.integer comboIter.list comboIter.logical comboIter.numeric comboIter.table permuteIter permuteIter.default permuteIter.factor permuteIter.integer permuteIter.list permuteIter.logical permuteIter.numeric permuteIter.table
Rank Combinations and PermutationscomboRank permuteRank
Sample Combinations and PermutationscomboSample comboSample.default comboSample.factor comboSample.integer comboSample.list comboSample.logical comboSample.numeric comboSample.table permuteSample permuteSample.default permuteSample.factor permuteSample.integer permuteSample.list permuteSample.logical permuteSample.numeric permuteSample.table
S4-class for Exposing C++ Constraints Class$,Constraints-method Constraints-class
Vectorized Factorization (Complete)divisorsRcpp
Generate Complete Factorization for Numbers in a RangedivisorsSieve
Apply Euler's Phi Function to Every Element in a RangeeulerPhiSieve
Cartesian ProductexpandGrid
Count of the Cartesian ProductexpandGridCount
expandGrid IteratorexpandGridIter
Sample the Cartesian ProductexpandGridSample
Vectorized Primality TestisPrimeRcpp
Apply Divisor Function to Every Element in a RangenumDivisorSieve
S4-class for Exposing C++ Partitions Class$,Partitions-method Partitions-class
Number of Partitions/CompositionscompositionsCount compositionsCount.default compositionsCount.table partitionsCount partitionsCount.default partitionsCount.table
Generate Partitions/CompositionscompositionsGeneral compositionsGeneral.default compositionsGeneral.table partitionsGeneral partitionsGeneral.default partitionsGeneral.table
Partition/Composition IteratorcompositionsIter compositionsIter.default compositionsIter.table partitionsIter partitionsIter.default partitionsIter.table
Rank Partitions/CompositionscompositionsRank partitionsRank
Sample Partitions/CompositionscompositionsSample compositionsSample.default compositionsSample.table partitionsSample partitionsSample.default partitionsSample.table
Prime Counting Function pi(x)primeCount
Vectorized Prime FactorizationprimeFactorize
Generate Prime Factorization for Numbers in a RangeprimeFactorizeSieve
Generate Prime NumbersprimeSieve
Max Number of Concurrent ThreadsstdThreadMax