[R] Computing time for matrix addition or subtraction

YONGWAN CHUN chun.49 at osu.edu
Mon Nov 13 04:33:41 CET 2006


Hello, 


I wonder by chance if there is a way to reduce computing time for matrix addition or subtraction. With a lot of iterations, it would be helpful to reduce a little amount time. 

Simple example is as below

n <- 2000
P <- matrix(rnorm(n*n),n,n)
PP <- P %*% P
M <- diag(n) - P
R <- M + t(M) - diag(n) +  PP

I would like to reduce time in calculating R. 

Thanks, 

Yongwan



More information about the R-help mailing list