[EMAIL PROTECTED] wrote:

> Hi,
> 
> x and y are (numeric) vectors. I wonder if one of the following is more
> efficient than the other:
> 
> x%*%y
> 
> or
> 
> sum(x*y)
> ?

I'd try

   x <- rnorm(1000000)
   y <- rnorm(1000000)
   system.time(x%*%y)
   system.time(sum(x*y))

and finally (hint, hint!):

   system.time(crossprod(x, y))

Uwe Ligges


> Thanks,
> Dimitri Szerman
> 
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to