
spam(x, nrow = 1, ncol = 1, eps = .Spam$eps)as.spam(x, eps = .Spam$eps)
is.spam(x)
x
such that
abs(x) < eps
set to zero. Defaults to eps = .Spam$eps
spam
object.
is.spam
returns TRUE
if x
is a spam
object.spam
and as.spam
act like matrix
and as.matrix
to coerce an object to a sparse matrix object of class spam
.
If x
is a list, it should contain either two or three elements.
In case of the former, the list should contain a n
by two
matrix of indicies (called ind
) and the values.
In case of the latter, the list should contain three vectors
containing the row, column indices (called i
and
j
) and the values. In both cases partial matching is done.
eps
should be at least as large as .Machine$double.eps
.
SPAM
general overview of the package.
spam.options
for details about the safemode
flag.
read.MM
and foreign
to create spam
matrices from MatrixMarket
files and from certain Matrix/SparseM
formats.# old message, do not loop, when you create a large sparse matrix
set.seed(13)
nz <- 128
ln <- nz^2
smat <- spam(0,ln,ln)
is <- sample(ln,nz)
js <- sample(ln,nz)
system.time(for (i in 1:nz) smat[is[i], js[i]] <- i)
system.time(smat[cbind(is,js)] <- 1:nz)
getClass("spam")
try(as.spam.numeric(NA))
Run the code above in your browser using DataLab