Displaying 2 results from an estimated 2 matches for "rownorm".
Did you mean:
lownorm
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,"+") -
2017 Jun 18
0
dist function in R is very slow
...code allocates at least five matrices of this size: outer(?), mtm, 2 * mtm, outer(?) - 2*mtm, and the final result obtained by taking the square root. [Actually, there is additional overhead for m*m (an even larger matrix) when computing the Euclidean norms, but this could be avoided with sq <- rowNorms(m, method="euclidean").]
I am usually more concerned about RAM than raw processing speed, so the package was designed to keep memory overhead as low as possible and allow users to work with realistic data sets on ordinary laptop computers.
> It takes less than 50 seconds for my (de...