[Rd] as.matrix.dist patch (performance)

Tim Taylor t|m@t@y|or @end|ng |rom h|ddene|eph@nt@@co@uk
Thu Aug 10 23:38:44 CEST 2023


Please find attached a small patch to improve the performance of 
as.matrix.dist().  It's a tiny bit more involved than the current code 
but does bring a reasonable speed improvement for larger <dist> objects 
(remaining comparable for smaller ones).

Example:

set.seed(1)
dat <- matrix(rnorm(20000), ncol = 2);
system.time(as.matrix(dist(dat)))

As of r84931:

    user  system elapsed
   3.370   1.154   4.535

With this patch:

    user  system elapsed
   1.925   0.754   2.685

Submitting here in the first instance but happy to move to Bugzilla if 
more appropriate.

Cheers

Tim

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 750 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20230810/d7ea5e3a/attachment.bin>


More information about the R-devel mailing list