multiply_sparse: Sparse-aware matrix multiplication (generic)

View source: R/S3_operations.R

multiply_sparseR Documentation

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, ...)

Arguments

x

An HDF5Matrix.

y

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

...

Additional arguments forwarded to the method.

Value

A new HDF5Matrix containing the product.

See Also

multiply_sparse.HDF5Matrix

Examples


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)




BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.