whichNonZero: Find non-zero entries of a matrix

Description Usage Arguments Value Author(s) See Also Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
whichNonZero(x, ...)

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

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

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

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 controlling how parallelization should be performed. only used when x is a DelayedMatrix object.

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 numeric vector of the values of the non-zero entries.

Author(s)

Aaron Lun

See Also

which, obviously.

Examples

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

scuttle documentation built on Dec. 19, 2020, 2 a.m.