spam (version 2.10-0)

isSymmetric: Test if a Sparse Matrix is Symmetric

Description

Efficient function to test if 'object' is symmetric or not.

Usage

# isSymmetric.spam(object, ...)
# S3 method for spam
isSymmetric(object, tol = 100 * .Machine$double.eps, ...)

Value

logical indicating if object is symmetric or not.

Arguments

object

a spam matrix.

tol

numeric scalar >= 0. Smaller differences are not considered, see all.equal.spam.

...

further arguments passed to all.equal.spam.

Author

Reinhard Furrer

Details

symmetry is assessed by comparing the sparsity structure of object and t(object) via the function all.equal.spam. If a difference is detected, the matrix is cleaned with cleanup and compared again.

See Also

all.equal.spam, cleanup.

Examples

Run this code
obj <- diag.spam(2)
isSymmetric(obj)

obj[1,2] <- .Machine$double.eps
isSymmetric(obj)
all.equal(obj, t(obj))

Run the code above in your browser using DataLab