inv_vec: Generate a permutation of a given length having a given...

Description Usage Arguments Value Examples

View source: R/inv-vec.R

Description

Generate a permutation of a given length having a given number of inversions

Usage

1
inv_vec(n, k, allow.dual = TRUE)

Arguments

n

A positive integer.

k

A nonnegative integer at most n.

allow.dual

Logical; whether to allow exchanging large values of k for their duals to improve efficiency.

Value

A permutation of n having k (non-arbitrary) inversions.

Examples

1
2
3
inv_vec(n = 5, k = choose(5, 2))
inv_vec(n = 5, k = 7)
inv_vec(n = 5, k = 7, allow.dual = FALSE)

corybrunson/tautable documentation built on March 29, 2021, 9:22 p.m.