[R] Faster matrix operation?

2010-06-01 Thread Remko Duursma
Dear R-helpers, I have a three-column matrix with lots of rows: xyzs - matrix(rnorm(3*10,0,1),ncol=3) # And I am multiplying it with some vector V, and summing the rows (columns after t()) in this way: V - c(2,3,4) system.time(vx - apply(t(xyzs) * V, 2 ,sum)) Ok, this does not take long

Re: [R] Faster matrix operation?

2010-06-01 Thread Bill.Venables
Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Remko Duursma Sent: Tuesday, 1 June 2010 4:04 PM To: r-help@r-project.org Subject: [R] Faster matrix operation? Dear R-helpers, I have a three-column matrix with lots of rows: xyzs - matrix(rnorm(3

Re: [R] Faster matrix operation?

2010-06-01 Thread Peter Ehlers
...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Remko Duursma Sent: Tuesday, 1 June 2010 4:04 PM To: r-help@r-project.org Subject: [R] Faster matrix operation? Dear R-helpers, I have a three-column matrix with lots of rows: xyzs- matrix(rnorm(3*10,0,1),ncol=3) # And I am

Re: [R] Faster matrix operation?

2010-06-01 Thread baptiste auguie
On 1 June 2010 11:34, Peter Ehlers ehl...@ucalgary.ca wrote: Or, for a very slight further reduction in time in the case of larger matrices/vectors:  as.vector(tcrossprod(V, xyzs)) I mention this merely to remind new users of the excellent speed of [t]crossprod().  -Peter Ehlers Thanks,