euclidean | R Documentation |
Function for calculating Euclidean distances between the rows of two matrices
fastPDist2(A, B)
A |
numerical matrix with dimesions |
B |
numerical matrix with dimesions |
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
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
Vicente Castellar Sebastiá
See the documentation for Armadillo, and RcppArmadillo, for more details.
A <- matrix(rnorm(5000), 500, 10) B <- matrix(rnorm(1000), 100, 10) fastPdist2(A, B)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.