matmult {rsparse}R Documentation

Multithreaded Sparse-Dense Matrix Multiplication

Description

Multithreaded %*%, crossprod, tcrossprod for sparse-dense matrix multiplication

Usage

## 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)

Arguments

x, y

dense matrix and sparse Matrix::RsparseMatrix / Matrix::CsparseMatrix matrices.

Details

Accelerates sparse-dense matrix multiplications using openmp. Applicable to the following pairs: (dgRMatrix, matrix), (matrix, dgRMatrix), (dgCMatrix, matrix), (matrix, dgCMatrix) combinations

Value

A dense matrix

Examples

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)

[Package rsparse version 0.3.3.4 Index]