Computes all pairwise \(l_p^p\) distances for a real matrix \(\mathbf{X}\), for a specified choice of Minkowski norm exponent \(p\).

getLpDistance(X, p)

Arguments

X

The \(N \times P\) real matrix

p

The power p of \(l_p^p\), i.e., \(||x||_p^p = (x_1^p+...x_n^p)\)

Value

A length \({N \choose 2}\) vector of pairwise \(l_p^p\) distances

Details

Dependencies: lp_distance from fast_dist_calc.cpp

Examples

X <- matrix(nrow = 5, ncol = 10, rnorm(50))
getLpDistance(X, p = 2)
#>  [1] 29.88774 11.51124 17.24888 17.69098 22.29190 24.56427 14.21610 21.12990
#>  [9]  9.80183 24.36827