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>
Dear Tim, ? Thu, 10 Aug 2023 22:38:44 +0100 Tim Taylor <tim.taylor at hiddenelephants.co.uk> ?????:> Submitting here in the first instance but happy to move to Bugzilla > if more appropriate.It's a fine patch. The 1.7 times speed up from not transposing the return value shouldn't be sneezed at. I think it's time to move it to Bugzilla so that it won't be completely forgotten. -- Best regards, Ivan