How to perform row-wise multiplication of a big.matrix in R?

212 Views Asked by At
  1. Suppose A is an R matrix. If I want to perform row-wise multiplication with elements from a vector vec, I could do:

sweep( A, 1, vec, "*" ).

Is there a similar, but efficient way to do the same if A was a big.matrix R object?

  1. My main goal is the following: I have two large matrices of dimension ~ 3500x3500 elements, A and B. I want to do the following operation:

B %*% sweep( A, 1, vec, "*" ).

I have to do these matrix multiplications over many iterations, but vec alone changes over each iteration. So I thought big.matrix/bigalgebra packages might offer convenient ways to do such matrix multiplications, but that row-wise multiplication needs to be dealt with. (I realize I can cast the vec entries as a diagonal big.matrix and do a full blown multiplication, but I would rather prefer dealing just with the diagonal entries like above.) Ay ideas / are there other alternative packages to do the same?

I greatly appreciate any help! Thanks!

0

There are 0 best solutions below