I want to subtract a vector from non zero values of a sparse matrix for e.g.
[,1] [,2] [,3] [,4]
[1,] 0 0 4 0
[2,] 0 5 0 3
[3,] 1 2 0 0
and here is the vector that i am trying to subtract:
[1 2 3]
so what i need in the end is:
[,1] [,2] [,3] [,4]
[1,] 0 0 3 0
[2,] 0 3 0 1
[3,] -2 -1 0 0
I did this by using sparse_matrix.A but it is consuming my memory when I am using the whole data set.
P.S. The dimensions of the matrix are too large and I do not want to use loops!