Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

C++ library containing a generic function to generate multiset combinations (n multichoose k) from vectors of any type

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitignore
Octocat-spinner-32 Makefile
Octocat-spinner-32 README
Octocat-spinner-32 multichoose.c
Octocat-spinner-32 multichoose.cpp
Octocat-spinner-32 multichoose.h
Octocat-spinner-32 multipermute.cpp
Octocat-spinner-32 multipermute.h
Multiset combinations, n multichoose k

Erik Garrison <>

multichoose.cpp --

This is a small C++ library/program which contains a generic function to
generate multisets for vectors of any type of object.  You can test out the
program using strings input from the command line by typing:

    % make


    % ./multichoose

Prints usage information:

    ./multichoose <k> <item1> <item2> ... <itemN>  ~ n multichoose k

Example usage:

    % ./multichoose 2 a t g c
    a a 
    a t 
    a g 
    a c 
    t t 
    t g 
    t c 
    g g 
    g c 
    c c 

This example lists all the possible *unordered' genotypes at a given genetic
loci of which there are two copies (e.g. chromosomes).  'k' (2 in this case)
could be understood as the expected ploidy of the given locus.  Applying
multiset permutations to each of the results would generate all possible
ordered multisets.

This library implements a multiset permutation generation method described in:

"Loopless Generation of Multiset Permutations using a Constant Number of
Variables by Prefix Shifts." Aaron Williams, 2009
Something went wrong with that request. Please try again.