[R] Speed up sum of outer products?
AjayT
ajaytalati at googlemail.com
Tue Mar 1 19:52:57 CET 2011
Hey thanks alot guys !!! That really speeds things up !!! I didn't know %*%
and crossprod, could operate on matrices. I think you've saved me hours in
calculation time. Thanks again.
> system.time({C=matrix(0,50,50);for(i in 1:n)C = C + (X[i,] %o% X[i,])})
user system elapsed
0.45 0.00 0.90
> system.time({C1 = t(X) %*% X})
user system elapsed
0.02 0.00 0.05
> system.time({C2 = crossprod(X)})
user system elapsed
0.02 0.00 0.02
--
View this message in context: http://r.789695.n4.nabble.com/Speed-up-sum-of-outer-products-tp3330160p3330378.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list