[R] crossprod and X %*% t(X)
Jon McAuliffe
jon at mcauliffe.com
Mon Jul 15 01:01:57 CEST 2002
hi,
the help page for crossprod states that crossprod(A,B) is faster than
t(A) %*% B; experimentation certainly bears this out. more alarming
is the evidence that crossprod(t(A), B) is faster than A %*% B:
on a PII laptop, 128MB memory, win98, R-1.5.0.-patched precompiled
(no ATLAS):
> A <- matrix(rnorm(250000),500,500)
> B <- matrix(rnorm(250000),500,500)
> for (i in 1:5) { print(system.time(A %*% B)) }
[1] NA NA 7.96 NA NA
[1] NA NA 7.81 NA NA
[1] NA NA 7.79 NA NA
[1] NA NA 7.81 NA NA
[1] NA NA 7.79 NA NA
> for (i in 1:5) { print(system.time(crossprod(t(A),B))) }
[1] NA NA 4.48 NA NA
[1] NA NA 4.51 NA NA
[1] NA NA 4.48 NA NA
[1] NA NA 4.69 NA NA
[1] NA NA 4.49 NA NA
is this expected, or is something strange about my system? would
ATLAS make this difference negligible? (i'd like to know before i spend
the time building and installing it.)
if it is expected, under what circumstances would one prefer %*%?
thanks
jon.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list