| matmult {rsparse} | R Documentation |
Multithreaded %*%, crossprod, tcrossprod
for sparse-dense matrix multiplication
## S4 method for signature 'dgRMatrix,matrix' x %*% y ## S4 method for signature 'dgRMatrix,matrix' tcrossprod(x, y) ## S4 method for signature 'matrix,dgCMatrix' x %*% y ## S4 method for signature 'matrix,dgCMatrix' crossprod(x, y)
x, y |
dense |
Accelerates sparse-dense matrix multiplications using openmp. Applicable to the following pairs:
(dgRMatrix, matrix), (matrix, dgRMatrix),
(dgCMatrix, matrix), (matrix, dgCMatrix) combinations
A dense matrix
library(Matrix)
data("movielens100k")
k = 10
nc = ncol(movielens100k)
nr = nrow(movielens100k)
x_nc = matrix(rep(1:k, nc), nrow = nc)
x_nr = t(matrix(rep(1:k, nr), nrow = nr))
csc = movielens100k
csr = as(movielens100k, "RsparseMatrix")
dense = as.matrix(movielens100k)
identical(csr %*% x_nc, dense %*% x_nc)
identical(x_nr %*% csc, x_nr %*% dense)