pairwise_product: pairwise_product

View source: R/RcppExports.R

pairwise_productR Documentation

pairwise_product

Description

Calculates pairwise_products from unique 2-element combinations of vector x. The output vector is the same length and same order as a lower triangle of matrix with rows and columns x.

Usage

pairwise_product(x)

Arguments

x

numeric vector.

Value

vector of pairwise_products, of length (l^2-l)/2, where l=length(x).

Author(s)

John L. Darcy

Examples

  # x <- 1:6
  # y_cpp <- pairwise_product(x)
  # y_r <- as.dist(outer(x, x, function(x,y){x*y}))
  # print("Calculated with R's outer() function:")
  # y_r
  # print("As a vector:")
  # as.vector(y_r)
  # print("Calculated with pairwise_product (C++):")
  # y_cpp

darcyj/specificity documentation built on Aug. 1, 2023, 8 a.m.