From phgrosjean at sciviews.org  Tue Nov 18 14:57:55 2003
From: phgrosjean at sciviews.org (Philippe Grosjean)
Date: Tue Nov 18 14:57:34 2003
Subject: [Rd] Power (^) 10x slower in R since version 1.7.1... What
	next?[Windows platform]
In-Reply-To: <Pine.LNX.4.44.0311181220240.1547-100000@gannet.stats>
Message-ID: <MABBLJDICACNFOLGIHJOCEPPDOAA.phgrosjean@sciviews.org>

Prof. Brian Ripley wrote:
>Why not use exp(y*log(x)) if it is adequate for your purposes?  It is
>faster under Windows.

With the CRAN version of R 1.8.0 under Win Xp:
>  system.time(exp(3.45*log(runif(1000000))))
[1] 1.30 0.06 1.49   NA   NA
> system.time(runif(1000000)^3.45)
[1] 7.14 0.03 7.20   NA   NA

With R compiled using MingW 2.0.1 on the same machine:
> system.time(exp(3.45*log(runif(1000000))))
[1] 1.31 0.02 1.35   NA   NA
> system.time(runif(1000000)^3.45)
[1] 1.04 0.00 1.04   NA   NA

OK, this is fine for me. I define:
"%^%" <- function(a, b) return(exp(b*log(a)))
which I use as a substitute for ^ to make sure performance does not drop too
much under Windows with the current CRAN version of R in my application.
Thanks,

Philippe Grosjean


[Rd] Power (^) 10x slower in R since version 1.7.1... What next?[Windows platform]
Philippe Grosjean