[Rd] Power (^) 10x slower in R since version 1.7.1... What
next?[Windows platform]
Philippe Grosjean
phgrosjean at sciviews.org
Tue Nov 18 14:57:55 MET 2003
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
More information about the R-devel
mailing list