Convert a sparse matrix to a dense matrix in a block-wise fashion
Source:R/utils.R
sparseToDenseMatrix.Rd
Convert a sparse matrix to a dense matrix in a block-wise fashion
Usage
sparseToDenseMatrix(
mat,
blockwise = TRUE,
chunk.by = "row",
chunk.size = 100000,
parallel = FALSE,
cores = 2
)
Examples
# make a sparse binary matrix
library(Matrix)
m <- 100
n <- 1000
mat <- round(matrix(runif(m * n), m, n))
mat.sparse <- Matrix(mat, sparse = TRUE)
# coerce back
mat.dense <- sparseToDenseMatrix(mat.sparse, chunk.size = 10)
#> Breaking into row chunks.
# make sure they are the same dimensions
dim(mat) == dim(mat.dense)
#> [1] TRUE TRUE
# make sure they are the same numerically
all(mat == mat.dense)
#> [1] TRUE