11% File src / library / base / man / isSymmetric.Rd
22% Part of the R package , https : // www.R - project.org
3- % Copyright 1995 - 2018 R Core Team
3+ % Copyright 1995 - 2025 R Core Team
44% Distributed under GPL 2 or later
55
66\name {isSymmetric }
1111 Generic function to test if \code {object } is symmetric or not.
1212 Currently only a matrix method is implemented , where a
1313 \code {\link {complex }} matrix \code {Z } must be \dQuote {Hermitian } for
14- \code {isSymmetric(Z )} to be true.
14+ \code {isSymmetric(Z )} to be true , and
15+ (since \R > = 4.5.0 ),
16+ \code {isSymmetric(Z , trans = " T" )} checks for \dQuote {simple } symmetry.
1517}
1618\usage {
1719isSymmetric(object , \dots )
1820\method {isSymmetric }{matrix }(object , tol = 100 * .Machine $ double.eps ,
19- tol1 = 8 * tol , \dots )
21+ tol1 = 8 * tol , trans = " C " , \dots )
2022}
2123\arguments {
2224 \item {object }{any \R object ; a \code {\link {matrix }} for the matrix method. }
@@ -26,6 +28,11 @@ isSymmetric(object, \dots)
2628 \sQuote {pre - tests } the first and last few rows for fast detection of
2729 \sQuote {obviously } asymmetric cases with this tolerance. Setting it
2830 to length zero will skip the pre - tests. }
31+ \item {trans }{a single \code {\link {character }}, only relevant for a
32+ \code {\link {complex }} matrix \code {Z }: if it is \code {" C" } (as by
33+ default ), \code {Conj(t(Z ))} must be the same as \code {Z } whereas
34+ otherwise (typically it is \code {" T" }) \code {t(Z )} must equal
35+ \code {Z }. The argument name is inherited from LAPACK. }
2936 \item {\dots }{further arguments passed to methods ; the matrix method
3037 passes these to \code {\link {all.equal }}. If the row and column
3138 names of \code {object } are allowed to differ for the symmetry check
@@ -55,8 +62,9 @@ isSymmetric(D3) # TRUE
5562isSymmetric(D3 , tol = 0 ) # FALSE for zero-tolerance
5663
5764# # Complex Matrices - Hermitian or not
58- Z <- sqrt(matrix (- 1 : 2 + 0i , 2 )); Z <- t(Conj(Z )) \%* \% Z
59- Z
65+ z <- sqrt(matrix (- 1 : 2 + 0i , 2 )); Z <- t(Conj(z )) \%* \% z
66+ ZtZ <- t(z ) \%* \% z
67+ Z ; ZtZ
6068isSymmetric(Z ) # TRUE
6169isSymmetric(Z + 1 ) # TRUE
6270isSymmetric(Z + 1i ) # FALSE -- a Hermitian matrix has a *real* diagonal
0 commit comments