Hi,
Let's assume that I have a vector
r <- rnorm(4)
and a matrix W
of dimension 20000*200 for example:
W <- matrix(rnorm(20000*200),20000,200)
I want to compute a new matrix M
of dimension 5000*200 such that m11 <- r%*%W[1:4,1]
, m21 <- r%*%W[5:8,1]
, m12 <- r%*%W[1:4,2]
etc. (i.e. grouping rows 4-by-4 and computing the product).
What's the optimal (speed,memory) way of doing this?
Thanks in advance.