- Suppose
A
is an R matrix. If I want to perform row-wise multiplication with elements from a vectorvec
, 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?
- My main goal is the following: I have two large matrices of dimension ~
3500x3500
elements,A
andB
. 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!