search for: euc_dist

Displaying 2 results from an estimated 2 matches for "euc_dist".

Did you mean: ecodist
2017 Jun 18
2
dist function in R is very slow
Hi Stefan, Thank you very much for pointing me to the wordspace package. It does the job a bit faster than my C code but is 100 times more convenient. By the way, since the tcrossprod function in the Matrix package is so fast, the Euclidean distance can be computed very fast: euc_dist <- function(m) {mtm <- Matrix::tcrossprod(m); sq <- rowSums(m*m);? sqrt(outer(sq,sq,"+") - 2*mtm)} It takes less than 50 seconds for my (dense) matrix of 5,054 rows and 12,803 columns, while dist.matrix with method="euclidean" takes almost 10 minutes (which is still ord...
2017 Jun 18
0
dist function in R is very slow
> By the way, since the tcrossprod function in the Matrix package is so fast, the Euclidean distance can be computed very fast: Indeed. > euc_dist <- function(m) {mtm <- Matrix::tcrossprod(m); sq <- rowSums(m*m); sqrt(outer(sq,sq,"+") - 2*mtm)} There are two reasons why I didn't use this optimization in "wordspace": 1) It can be inaccurate for small distances between vectors of large Euclidean length becaus...