[Rd] speedup for as.matrix.dist

2009-04-18 Thread Romain Francois
Hello, I am trying to patch as.matrix.dist to achieve some speedup. > m <- expand.grid( x = 1:20, y = 1:20, z = 1:20 ) > d <- dist( m ) > system.time( out <- stats:::as.matrix.dist( d ) ) user system elapsed 15.355 3.110 19.123 > system.time( out <- as.matrix.dist( d ) ) user system ela

Re: [Rd] speedup for as.matrix.dist

2009-04-24 Thread Romain Francois
Hi, I found the init.c file I did not see before. > m <- expand.grid( x = 1:20, y = 1:20, z = 1:20 ) > d <- dist( m ) > system.time( out <- as.matrix( d ) ) user system elapsed 3.006 1.252 4.429 > old.as.matrix.dist <- function(x, ...) + { + size <- attr(x, "Size") + df <- matrix