From t|m@t@y|or @end|ng |rom h|ddene|eph@nt@@co@uk  Thu Aug 10 23:38:44 2023
From: t|m@t@y|or @end|ng |rom h|ddene|eph@nt@@co@uk (Tim Taylor)
Date: Thu, 10 Aug 2023 22:38:44 +0100
Subject: [Rd] as.matrix.dist patch (performance)
Message-ID: <c919dc37-e226-3b9c-74a8-455c5dea79af@hiddenelephants.co.uk>

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>


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