Displaying 1 result from an estimated 1 matches for "nonzero_m".
Did you mean:
nonzero
2010 Dec 06
1
Sparse matrix performance question
I have a very sparse square matrix which is < 20K rows & columns and I am
trying to row standardize the matrix for the rows that have non-missing
value as follows:
row_sums <- rowSums(M,na.rm=TRUE)
nonzero_idxs <- which(row_sums>0)
nonzero_M <- M[nonzero_idxs,]/row_sums[nonzero_idxs]
M[nonzero_idxs,] <- nonzero_M
Each line completes well under a second except the last line which takes
well over 10 seconds which is simply assigning the sub-matrix of rows that
have non-missing values to the complete matrix. I am curious to know wh...