Learn R Programming

BigDataStatMeth (version 2.0.3)

multiply_sparse: Sparse-aware matrix multiplication (generic)

Description

Generic function for block-wise sparse matrix multiplication. The method for HDF5Matrix computes x %*% y using the BigDataStatMeth sparse multiplication algorithm, which skips all-zero blocks and is more efficient when one or both matrices are highly sparse.

Usage

multiply_sparse(x, y, ...)

Value

A new HDF5Matrix containing the product.

Arguments

x

An HDF5Matrix.

y

An HDF5Matrix. Must be in the same HDF5 file as x.

...

Additional arguments forwarded to the method.

See Also

multiply_sparse.HDF5Matrix

Examples

Run this code
# \donttest{
fn <- tempfile(fileext = ".h5")
X  <- hdf5_create_matrix(fn, "data/A", data = matrix(rnorm(100), 10, 10))
X  <- hdf5_create_matrix(fn, "data/B", data = matrix(rnorm(100), 10, 10))


A <- hdf5_matrix(fn, "data/A")
B <- hdf5_matrix(fn, "data/B")
C <- multiply_sparse(A, B)

hdf5_close_all()
unlink(fn)

# }

Run the code above in your browser using DataLab