isSymmetric-methods | R Documentation |
Tests whether its argument is a symmetric square matrix, by default
tolerating some numerical fuzz and requiring symmetric dimnames
in addition to symmetry in the mathematical sense.
isSymmetric
is a generic function in base, which has a
method for traditional matrices of implicit class
matrix
. Documented here are methods in package Matrix
for subclasses of virtual class Matrix
.
## S4 method for signature 'denseMatrix'
isSymmetric(object, tol = 100 * .Machine$double.eps, tol1 = 8 * tol,
trans = "C", checkDN = TRUE, ...)
## S4 method for signature 'CsparseMatrix'
isSymmetric(object, tol = 100 * .Machine$double.eps,
trans = "C", checkDN = TRUE, ...)
## S4 method for signature 'RsparseMatrix'
isSymmetric(object, tol = 100 * .Machine$double.eps,
trans = "C", checkDN = TRUE, ...)
## S4 method for signature 'TsparseMatrix'
isSymmetric(object, tol = 100 * .Machine$double.eps,
trans = "C", checkDN = TRUE, ...)
## S4 method for signature 'diagonalMatrix'
isSymmetric(object, tol = 100 * .Machine$double.eps,
trans = "C", checkDN = TRUE, ...)
## S4 method for signature 'indMatrix'
isSymmetric(object, checkDN = TRUE, ...)
object |
a |
tol , tol1 |
see |
trans |
a character string, |
checkDN |
a logical indicating whether symmetry of the
|
... |
further arguments passed from or to other methods.
Notably, for numeric or complex (but not integer, logical,
or pattern) |
The Dimnames
slot of object
, say dn
,
is considered to be symmetric if and only if
dn[[1]]
and dn[[2]]
are identical or
one is NULL
; and
ndn <- names(dn)
is NULL
or
ndn[1]
and ndn[2]
are identical or
one is the empty string ""
.
Hence list(a=nms, a=nms)
is considered to be symmetric
and so too are list(a=nms, NULL)
and list(NULL, a=nms)
.
Note that this definition is looser than that employed by
isSymmetric.matrix
, which requires dn[1]
and
dn[2]
to be identical, where dn
is the dimnames
attribute of a traditional matrix.
A logical, either TRUE
or FALSE
(never NA
).
forceSymmetric
, symmpart
, skewpart
;
virtual class symmetricMatrix
and its subclasses.
isSymmetric(Diagonal(4)) # TRUE of course
M <- Matrix(c(1,2,2,1), 2,2)
isSymmetric(M) # TRUE (*and* of formal class "dsyMatrix")
isSymmetric(as(M, "generalMatrix")) # still symmetric, even if not "formally"
isSymmetric(triu(M)) # FALSE
## Look at implementations:
showMethods("isSymmetric", includeDefs = TRUE) # includes S3 generic from base
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.