R: optimal way of computing the "product" of two vectors -
Assuming I have a vector
r
,rnorm (4) and a matrix
w
dimension 20000 * 200:w < - I want to calculate a new matrix
M
dimension 5000 * 200; matrix (rnorm (20000 * 200), 20000,200)Code> m11 & lt; - r% *% W [1: 4,1]
m21 & lt; - r% *% W [5: 8,1]
,m12 & lt; - r% *% w [1: 4,2]
etc. (i.e. calculating four to four-fourth productive sections and product).What is the optimal (speed, memory) way of doing this?
Thanks in advance.
This seems to run fastest for me:
array (R% *% array (w, c (4, 20000 * 200/4)), c (5000, 200))
Comments
Post a Comment