sum_rowcolCumsum {ccmap} | R Documentation |
Equivalent to computing the cumulative sum of a matrix over rows, then over columns, then suming every value (though much faster and more memory efficient).
sum_rowcolCumsum(x, i, j)
x |
Numeric vector of non-zero values of matrix. |
i |
Integer vector of row indices of x. |
j |
Integer vector of column indices of x. |
Numeric value equal to the sum of the cumulative sum computed over rows then columns of a matrix.
x <- c(1, 1, 1, -1) # non-zero values of matrix i <- c(1, 2, 3, 4) # row indices of x j <- c(4, 1, 3, 2) # col indices of x sum_rowcolCumsum(x, i, j)