combn_fast {tsmarch}R Documentation

Fast combination of n elements, taken m at a time

Description

Fast combination of n elements, taken m at a time

Usage

combn_fast(x, m)

Arguments

x

integer vector source for combinations

m

number of elements to choose.

Details

This is a significantly faster version of combn. For an integer vector x of length 1000 and m of 3 which results in a matrix of size 3 x 166,167,000, the speed improvement is about 9 times (11 secs vs 99 secs). This code is written using Armadillo C++ and 64 bit unsingned integers.

Value

a matrix with m rows.

Examples

all.equal(combn(1:10, 3), combn_fast(1:10,3))

[Package tsmarch version 1.0.0 Index]