whichNonZero: Find non-zero entries of a matrix

whichNonZeroR Documentation

Find non-zero entries of a matrix

Description

Finds the non-zero entries of a matrix in the most efficient manner for each matrix representation. Not sure there's much more to say here.

Usage

whichNonZero(x, ...)

## S4 method for signature 'ANY'
whichNonZero(x, ...)

## S4 method for signature 'TsparseMatrix'
whichNonZero(x, ...)

## S4 method for signature 'CsparseMatrix'
whichNonZero(x, ...)

## S4 method for signature 'SparseArraySeed'
whichNonZero(x, ...)

## S4 method for signature 'DelayedMatrix'
whichNonZero(x, BPPARAM = NULL, ...)

Arguments

x

A numeric matrix-like object, usually sparse in content if not in representation.

...

For the generic, additional arguments to pass to the specific methods.

For the methods, additional arguments that are currently ignored.

BPPARAM

A BiocParallelParam object from the BiocParallel package controlling how parallelization should be performed. Only used when x is a DelayedMatrix object; defaults to no parallelization.

Value

A list containing i, an integer vector of the row indices of all non-zero entries; j, an integer vector of the column indices of all non-zero entries; and x, a (usually atomic) vector of the values of the non-zero entries.

Author(s)

Aaron Lun

See Also

which, obviously.

Examples

x <- Matrix::rsparsematrix(1e6, 1e6, 0.000001)
out <- whichNonZero(x)
str(out)


LTLA/beachmat documentation built on April 1, 2024, 1:22 p.m.