Eliminates an zeros in a sparse matrix.

cleanup(x, eps = getOption("spam.eps"))

Arguments

x

a sparse matrix of class spam.

eps

numeric scalar > 0. Smaller entries are coerced to zero.

Details

A sparse matrix may still contain zeros. This function (aliased to as.spam) filters these values.
This often causes confusion when testing such matrices for symmetry or comparing apparently equal matrices with all.equal (see ‘Examples’ below.

Author

Reinhard Furrer

Examples

A <- diag.spam(2)
A[1,2] <- 0

all.equal(A, t(A))
#> [1] "Column-sparsity structure differ (at least 1 instance(s))"
#> [2] "Row-sparsity structure differ (at least 1 instance(s))"   
isSymmetric.spam(A)
#> [1] TRUE
all.equal(cleanup(A), diag.spam(2))
#> [1] TRUE