EVOLUTION-MANAGER
Edit File: isSymmetric.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Test if a Matrix or other Object is Symmetric (Hermitian)</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for isSymmetric {base}"><tr><td>isSymmetric {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Test if a Matrix or other Object is Symmetric (Hermitian)</h2> <h3>Description</h3> <p>Generic function to test if <code>object</code> is symmetric or not. Currently only a matrix method is implemented, where a <code><a href="complex.html">complex</a></code> matrix <code>Z</code> must be “Hermitian” for <code>isSymmetric(Z)</code> to be true. </p> <h3>Usage</h3> <pre> isSymmetric(object, ...) ## S3 method for class 'matrix' isSymmetric(object, tol = 100 * .Machine$double.eps, tol1 = 8 * tol, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>object</code></td> <td> <p>any <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> object; a <code><a href="matrix.html">matrix</a></code> for the matrix method.</p> </td></tr> <tr valign="top"><td><code>tol</code></td> <td> <p>numeric scalar >= 0. Smaller differences are not considered, see <code><a href="all.equal.html">all.equal.numeric</a></code>.</p> </td></tr> <tr valign="top"><td><code>tol1</code></td> <td> <p>numeric scalar >= 0. <code>isSymmetric.matrix()</code> ‘pre-tests’ the first and last few rows for fast detection of ‘obviously’ asymmetric cases with this tolerance. Setting it to length zero will skip the pre-tests.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments passed to methods; the matrix method passes these to <code><a href="all.equal.html">all.equal</a></code>. If the row and column names of <code>object</code> are allowed to differ for the symmetry check do use <code>check.attributes = FALSE</code>!</p> </td></tr> </table> <h3>Details</h3> <p>The <code><a href="matrix.html">matrix</a></code> method is used inside <code><a href="eigen.html">eigen</a></code> by default to test symmetry of matrices <em>up to rounding error</em>, using <code><a href="all.equal.html">all.equal</a></code>. It might not be appropriate in all situations. </p> <p>Note that a matrix <code>m</code> is only symmetric if its <code>rownames</code> and <code>colnames</code> are identical. Consider using <code><a href="unname.html">unname</a>(m)</code>. </p> <h3>Value</h3> <p>logical indicating if <code>object</code> is symmetric or not. </p> <h3>See Also</h3> <p><code><a href="eigen.html">eigen</a></code> which calls <code>isSymmetric</code> when its <code>symmetric</code> argument is missing. </p> <h3>Examples</h3> <pre> isSymmetric(D3 <- diag(3)) # -> TRUE D3[2, 1] <- 1e-100 D3 isSymmetric(D3) # TRUE isSymmetric(D3, tol = 0) # FALSE for zero-tolerance ## Complex Matrices - Hermitian or not Z <- sqrt(matrix(-1:2 + 0i, 2)); Z <- t(Conj(Z)) %*% Z Z isSymmetric(Z) # TRUE isSymmetric(Z + 1) # TRUE isSymmetric(Z + 1i) # FALSE -- a Hermitian matrix has a *real* diagonal colnames(D3) <- c("X", "Y", "Z") isSymmetric(D3) # FALSE (as row and column names differ) isSymmetric(D3, check.attributes=FALSE) # TRUE (as names are not checked) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>