Virtual Class of Symmetric Matrices in Package Matrix
Virtual Class of Symmetric Matrices in Package Matrix
The virtual class of symmetric matrices, "symmetricMatrix", from the package Matrix contains numeric and logical, dense and sparse matrices, e.g., see the examples with the actual
subclasses.
The main use is in methods (and C functions) that can deal with all symmetric matrices, and in as(*, "symmetricMatrix").
class
Slots
Dim, Dimnames: inherited from virtual class Matrix. See comments below about symmetry of Dimnames.
factors: a list of MatrixFactorization objects caching factorizations of the matrix. Typically, it is initialized as an empty list and updated automagically whenever a factorization is computed.
uplo: a character string, either "U" or "L" indicating that only entries in the upper or lower triangle are referenced.
Extends
Class "Matrix", directly.
Methods
dimnames: signature(object = "symmetricMatrix"): returns symmetricdimnames, even when the Dimnames slot only has row or column names. This allows to save storage for large (typically sparse) symmetric matrices.
called by the internal validity checking functions, and also from getValidity(getClass("symmetricMatrix")).
Validity and dimnames
The validity checks do not require a symmetric Dimnames slot, so it can be list(NULL, <character>), e.g., for efficiency. However, dimnames() and other functions and methods should behave as if the dimnames were symmetric, i.e., with both list components identical.
See Also
isSymmetric which has efficient methods (isSymmetric-methods ) for the Matrix classes. Classes triangularMatrix, and, e.g., dsyMatrix for numeric dense matrices, or lsCMatrix for a logical sparse matrix class.
Examples
## An example about the symmetric Dimnames:sy <- sparseMatrix(i= c(2,4,3:5), j= c(4,7:5,5), x =1:5, dims = c(7,7), symmetric=TRUE, dimnames = list(NULL, letters[1:7]))sy # shows symmetrical dimnamessy@Dimnames # internally only one part is storeddimnames(sy)# both parts - as sy *is* symmetricalshowClass("symmetricMatrix")## The names of direct subclasses:scl <- getClass("symmetricMatrix")@subclasses
directly <- sapply(lapply(scl, slot,"by"), length)==0names(scl)[directly]## Methods -- applicaple to all subclasses above:showMethods(classes ="symmetricMatrix")