pairwise_combination_indices: Compute all pairwise combinations of indices

View source: R/RcppExports.R

pairwise_combination_indicesR Documentation

Compute all pairwise combinations of indices

Description

Fast computation of indices of all pairwise element of a vector of length n.

Usage

pairwise_combination_indices(n, self = FALSE)

Arguments

n

A number giving the number of elements to create all pairwise indices from

self

A logical that determines whether a column should also be multiplied by itself.

Details

Note that the output order of columns corresponds to the order of the columns in x. First column 1 is multiplied with each of the other columns, then column 2 with the remaining columns etc.

Value

A matrix with n*(n+1)/2 rows (if self=TRUE) or n*(n-1)/2 rows (if self=FALSE, the default) and two columns gicing all possible combinations of indices.

Author(s)

Claus Ekstrom <claus@rprimer.dk>

Examples


pairwise_combination_indices(3)
pairwise_combination_indices(4, self=TRUE)


MESS documentation built on Aug. 21, 2023, 1:05 a.m.