spam {spam}R Documentation

Sparse Matrix Class

Description

This group of functions evaluates and coerces changes in class structure.

Usage

spam(x, nrow = 1, ncol = 1, eps = .Spam$eps)

as.spam(x, eps = .Spam$eps)

is.spam(x)

Arguments

x is a matrix, or vector object, of either dense or sparse form
nrow number of rows of matrix
ncol number of columns of matrix
eps A tolerance parameter: elements of x such that abs(x) < eps set to zero. This argument is only relevant when coercing matrices from dense to sparse form. Defaults to eps = .Spam$eps

Details

The function as.spam acts like matrix to coerce a vector object to a sparse matrix object of class spam.

See Also

SPAM general overview of the package.

Examples

# old message, do not loop, when you create a large sparse matrix
nz <- 128
ln <- nz^2
smat <- spam(0,ln,ln)
system.time(for (i in 1:nz) smat[sample(ln,1),sample(ln,1)] <- i)
system.time(smat[cbind(sample(ln,nz),sample(ln,nz))] <- 1:nz)

getClass("spam")


[Package spam version 0.12 Index]