SFBM-class {bigsparser}R Documentation

Class SFBM

Description

A reference class for storing and accessing sparse matrix-like data stored in files on disk.

Convert a 'dgCMatrix' or 'dsCMatrix' to an SFBM.

Usage

as_SFBM(spmat, backingfile = tempfile(), compact = FALSE)

Arguments

spmat

A 'dgCMatrix' (non-symmetric sparse matrix of type 'double') or 'dsCMatrix' (symmetric sparse matrix of type 'double').

backingfile

Path to file where to store data. Extension .sbk is automatically added.

compact

Whether to use a compact format? Default is FALSE. This is useful when non-zero values in columns are contiguous (or almost).

Details

An object of class SFBM has many fields:

And some methods:

Value

The new SFBM.

Examples

spmat2 <- Matrix::Diagonal(4, 0:3)
spmat2[4, 2] <- 5
spmat2[1, 4] <- 6
spmat2[3, 4] <- 7
spmat2

# Stores all (i, x) for x != 0
(X2 <- as_SFBM(spmat2))
matrix(readBin(X2$sbk, what = double(), n = 100), 2)

# Stores only x, but all (even the zero ones) from first to last being not 0
(X3 <- as_SFBM(spmat2, compact = TRUE))
X3$first_i
readBin(X3$sbk, what = double(), n = 100)

[Package bigsparser version 0.6.1 Index]