Skip to content

multicool

1.0.2Package record

Permutations of Multisets in Cool-Lex Order

9packages depend
450.1Kdownloads / year
–test coverage
12/13flavors OK

Overview

About

A set of tools to permute multisets without loops or hash tables and to generate integer partitions. The permutation functions are based on C code from Aaron Williams. Cool-lex order is similar to colexicographical order. The algorithm is described in Williams, A. Loopless Generation of Multiset Permutations by Prefix Shifts. SODA 2009, Symposium on Discrete Algorithms, New York, United States. The permutation code is distributed without restrictions. Multinomial coefficients, Stirling numbers of the second kind and Bell numbers are computed exactly using the 'gmp' package. The package also generates the integer partitions of a positive, non-zero integer n. The C++ code for this is based on Python code from Jerome Kelleher, and the algorithm is described in Kelleher and O'Sullivan (2009) doi:10.48550/arXiv.0909.2331. The C++ code and Python code are distributed without conditions.

Changes in 1.0.2

New features

  • allPerm() has a new argument nThreads to generate large results (at least 100,000 permutations) with several threads. It is about 1.4 to 1.9 times faster with 2 to 4 threads, and close to the speed at which the result can be written to memory. Character and factor multisets always use one thread. The default nThreads = 1 works as before.
  • nextPerm() has a new argument n to return the next n permutations as the rows of a matrix (fewer at the end, then FALSE). This makes iterating through permutations much faster, while only holding n of them in memory. For example, nextPerm(m, 1000) costs about 0.016 microseconds per permutation, the same as allPerm(). The default n = 1 works as before.
  • multinom(), Stirling2()/S2() and Bell()/B() are now computed exactly using the 'gmp' package, and have a new argument exact. By default they still return doubles, now correct to double precision rather than silently overflowing. With exact = TRUE they return exact big integers of class bigz. The useDouble argument of multinom() is kept for backwards compatibility but no longer has any effect.
Show all changes in 1.0.2Hide the rest of the changes in 1.0.2

Changes in behaviour

  • initMC() now gives an error, rather than a warning, for input with fewer than two elements, and an error for input containing missing values.
  • initMC() keeps the type of its input, so logical multisets are permuted as logicals rather than as the strings "TRUE" and "FALSE".

Bug fixes

  • initMC() with non-whole numbers (e.g. c(1.5, 1.5, 2.5)) permuted the counts of each value rather than the values themselves.
  • Stirling2() and Bell() overflowed for moderate arguments, and much sooner on Windows (e.g. Stirling2(20, 5) and Bell(16) were wrong).
  • multinom() overflowed silently for large coefficients.
  • genComp() crashed R when n was zero or negative, and returned NULL when len was greater than n.
  • Calling allPerm() no longer resets the position of nextPerm().
  • Fixed a memory leak in the permutation object.

Improvements

  • genComp() is much faster for larger n. The time taken previously grew quadratically with the number of partitions (about 100 seconds for n = 50).
  • allPerm() is 10 to 30 times faster and uses much less memory. It writes the elements straight into the result matrix in C++. In the permutation benchmarks from <https://stackoverflow.com/questions/22569176>, it now takes 1.4 to 1.9 times as long as single-threaded 'RcppAlgos' (before, 15 to 54 times as long), and 1.0 to 1.5 times as long as 'arrangements'.
  • initMC() keeps integer input as integer, so allPerm() returns an integer matrix for integer input.
  • nextPerm() is about 9 times faster per call (about 0.9 rather than 8.4 microseconds), because the permutation object is now reached through an external pointer rather than an Rcpp Module.
  • nextPerm() checks that its argument is an mc object.
  • Using an mc object after it has been saved and reloaded gives a clear error asking you to call initMC() again.
  • Native routines are now registered, and documentation and NAMESPACE are generated with roxygen2.

Acknowledgements

  • Earlier versions of this package used C++ code by Dave Barber (<http://tamivox.org/dave/multinomial/code.html>) to compute multinomial coefficients. It has been replaced by exact computation with the 'gmp' package, but we thank Dave for the code that the package relied on for many years.

From NEWS.md in the release

Install

Health

CRAN checks
1NOTE12OK
Check messages
NOTECRAN incoming feasibilityr-devel-linux-x86_64-debian-clang
Maintainer: ‘James Curran <j.curran@auckland.ac.nz>’

No Authors@R field in DESCRIPTION.
Please add one, modifying
  Authors@R: c(person(given = "James",
                      family = "Curran",
                      role = c("aut", "cre"),
                      email = "j.curran@auckland.ac.nz"),
               person(given = "Aaron",
                      family = "Williams",
                      role = "aut"),
               person(given = "Jerome",
                      family = "Kelleher",
                      role = "aut"),
               person(given = "Dave",
                      family = "Barber",
                      role = "aut"))
as necessary.

CRAN check page ↗

Slowest check: 2.6 min · r-devel-windows-x86_64
Status changes
  • NOTE12 OK, 1 NOTENow
  • NOTE12 OK, 2 NOTE2026-04-22
  • ERROR11 OK, 2 NOTE, 1 ERROR2026-04-18
  • NOTE12 OK, 2 NOTE2026-03-10
Advisories

none known

Documentation

In release 1.0.2
READMEYes · 2 wordsVignettesNoNEWSYes · 67% structured · mentions 1.0.2Citation fileNoWebsitenot declared in DESCRIPTION
Help pages
8 (1 internal)includes a package overview page
Examples that run
100%7 run in a plain check
Exported functions with examples
100%
Documented parameters
100%
Return-value docs
100%
Help pages citing references
38%

Downloads

450.1K
CRAN downloads in the past year
Rank #627 · ~1.2K/day · ~37.5K/mo
Daily download trend is not available in this view yet.
33.7K30 days
93.4K90 days
450.1K1 year
Compare downloads with other packages →
Also on13.4K r2u2 autocran12.2K conda_forge27.6K bioconda350 c2d4u

Repository

2Stars
2Forks
1Open issues
0Open PRs
1Releases
39Commits
3Commit identities
39 commits · Last activity 2026-10-22
Responsiveness
How these are sampled
PRs merged (all time)
100%
Median days to close, 50 most recently updated closed issues
not measured
Median days to close, 50 most recently updated closed PRs
2

Stars over time

2024-07-20 · 22026-07-07 · 2
PracticesBeta

3 development-tooling and community-health practices detected across 3 families in the upstream repository

Checks run against github.com/jmcurran/multicool on 2026-10-21.

Continuous integration (1)
GitHub Actions
CRAN release process (1)
cran-comments.md
Lint, format, editor (1)
RStudio project
How this is detected·Detection ruleset v4 (2026-10-20)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • Claude Codefirst seen 2026-10-19
    Seen in the repository: CLAUDE.md
    Named in .Rbuildignore: CLAUDE.md
    Commits: at least 9 crediting it in the message
Models named in its commits
  • Claude Opus 5.59 commits · Oct 2026
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
3 external dependencies (excludes base and recommended)

Installing multicool adds 2 packages (2 with compiled code, 2.0 MB of source tarballs). Heaviest: Rcpp 1.8 MB, gmp 163 KB.

Depends (2)
methodsRcpp
Imports (1)
LinkingTo (1)
Suggests (0)
none
Enhances (0)
none
Reverse dependencies
9direct
274indirect
Imports 9
Depends, Imports or LinkingTo, most downloaded first

People & History

People (3)
Author, Maintainer · added in 0.1-5
Author · added in 0.1-5
Author · added in 0.1-2

Maintainer since 0.1-1 (2011)

Listed in earlier versions (2)
no longer listed · 0.1-1 to 0.1-2
Dave Barber
no longer listed · 0.1-2 to 1.0.1
Releases (13)

Pick two releases to compare their code metrics.

  • 1.0.2Latest
    record
    2026-10-21 · current release · diff ↗ ·
    14 hours in CRAN's queue
    Listed in CRAN's incoming queue from 2026-10-20 21:03 to 2026-10-21 10:55 UTC, in 4 readings.
  • R
    R 4.6.0 released · 2026-04-24
  • R
    R 4.5.0 released · 2025-04-11
  • R
    R 4.4.0 released · 2024-04-24
  • 1.0.1
    record
    2024-02-05 · diff ↗
  • 1.0.0
    record
    2023-12-02 · diff ↗
  • R
    R 4.3.0 released · 2023-04-21
  • R
    R 4.2.0 released · 2022-04-22
  • 0.1-12
    record
    2021-06-29 · diff ↗
  • R
    R 4.1.0 released · 2021-05-18
  • R
    R 4.0.0 released · 2020-04-24
  • 0.1-11
    record
    2019-12-05 · diff ↗
  • R
    R 3.6.0 released · 2019-04-26
  • R
    R 3.5.0 released · 2018-04-23
  • R
    R 3.4.0 released · 2017-04-21
  • 0.1-10
    record
    2016-11-25 · diff ↗
Show 13 earlier eventsHide 13 earlier events
  • R
    R 3.3.0 released · 2016-05-03
  • 0.1-9
    record
    2015-10-28 · diff ↗
  • 0.1-8
    record
    2015-10-22 · diff ↗
  • 0.1-7
    record
    2015-08-17 · diff ↗
  • 0.1-6
    record
    2015-04-28 · diff ↗
  • R
    R 3.2.0 released · 2015-04-16
  • 0.1-5
    record
    2015-02-26 · diff ↗ ·
    added 5 exports
    B, Bell, genComp, S2, Stirling2
  • R
    R 3.1.0 released · 2014-04-10
  • 0.1-2
    record
    2013-07-10 · diff ↗ ·
    added 2 exports
    allPerm, multinom
  • R
    R 3.0.0 released · 2013-04-03
  • R
    R 2.15.0 released · 2012-03-30
  • 0.1-1
    record
    2011-11-15
  • R
    R 2.14.0 released · 2011-10-31
Across CRAN, the median accepted release of the past year spent 23 hours in the queue, 90% under 11 days.How queue time is measured

Package metadata

First published
2011-11-15
Total releases
13 / 15 yrs
License
GPL-2 OSI
Download size
20 KB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("multicool")
Curran, J., Kelleher, J., & Williams, A. (2026). multicool: Permutations of Multisets in Cool-Lex Order (Version 1.0.2) [Computer software]. https://doi.org/10.32614/CRAN.package.multicool

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for multicool version 1.0.2 [Data set]. HJJB, LLC. Data release v2026-10-23. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-23, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy