toCsparse: Convert a SparseMatrix to a CsparseMatrix

View source: R/toCsparse.R

toCsparseR Documentation

Convert a SparseMatrix to a CsparseMatrix

Description

Exactly what it says in the title.

Usage

toCsparse(x)

Arguments

x

Any object produced by block processing with colBlockApply or rowBlockApply. This can be a matrix, sparse matrix or a SparseMatrix object from the SparseArray package.

Details

This is intended for use inside functions to be passed to colBlockApply or rowBlockApply. The idea is to pre-process blocks for user-defined functions that don't know how to deal with SparseMatrix objects, which is often the case for R-defined functions that do not benefit from beachmat's C++ abstraction.

Value

x is returned unless it is a SparseMatrix object from the SparseArray package, in which case an appropriate CsparseMatrix object is returned instead.

Author(s)

Aaron Lun

Examples

library(SparseArray)
out <- COO_SparseArray(c(10, 10),
    nzcoo=cbind(1:10, sample(10)),
    nzdata=runif(10))
toCsparse(out)


LTLA/beachmat documentation built on Nov. 15, 2024, 10:19 p.m.