euclidean: Euclidean distances between the rows of two matrices

euclideanR Documentation

Euclidean distances between the rows of two matrices

Description

Function for calculating Euclidean distances between the rows of two matrices

Usage

fastPDist2(A, B)

Arguments

A

numerical matrix with dimesions (m, k)

B

numerical matrix with dimesions (n, k)

Details

The euclidean distance between two vectors $x$ e $y$ is

||x-y||_2 = (∑_{i=1}^k (x_i - y_i)^2)^{1/2}

We use the property (x - y)^2 = x^2 -2xy + y^2 for increase the speed

Value

A numeric matrix with dimensions (m, n) where (i, j) is the euclidean distance between the row i of mnatrix A and the row j of matrix B

Author(s)

Vicente Castellar Sebastiá

References

See the documentation for Armadillo, and RcppArmadillo, for more details.

Examples

  A <- matrix(rnorm(5000), 500, 10)
  B <- matrix(rnorm(1000), 100, 10)
  fastPdist2(A, B)

vcastellar/fastDist documentation built on Feb. 10, 2023, 8:17 a.m.