EVOLUTION-MANAGER
Edit File: norm.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: Compute the Norm of a Matrix</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 norm {base}"><tr><td>norm {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Compute the Norm of a Matrix</h2> <h3>Description</h3> <p>Computes a matrix norm of <code>x</code> using LAPACK. The norm can be the one (<code>"O"</code>) norm, the infinity (<code>"I"</code>) norm, the Frobenius (<code>"F"</code>) norm, the maximum modulus (<code>"M"</code>) among elements of a matrix, or the “spectral” or <code>"2"</code>-norm, as determined by the value of <code>type</code>. </p> <h3>Usage</h3> <pre> norm(x, type = c("O", "I", "F", "M", "2")) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>numeric matrix; note that packages such as <a href="https://CRAN.R-project.org/package=Matrix"><span class="pkg">Matrix</span></a> define more <code>norm()</code> methods.</p> </td></tr> <tr valign="top"><td><code>type</code></td> <td> <p>character string, specifying the <em>type</em> of matrix norm to be computed. A character indicating the type of norm desired. </p> <dl> <dt><code>"O"</code>, <code>"o"</code> or <code>"1"</code></dt><dd><p>specifies the <b>o</b>ne norm, (maximum absolute column sum);</p> </dd> <dt><code>"I"</code> or <code>"i"</code></dt><dd><p>specifies the <b>i</b>nfinity norm (maximum absolute row sum);</p> </dd> <dt><code>"F"</code> or <code>"f"</code></dt><dd><p>specifies the <b>F</b>robenius norm (the Euclidean norm of <code>x</code> treated as if it were a vector);</p> </dd> <dt><code>"M"</code> or <code>"m"</code></dt><dd><p>specifies the <b>m</b>aximum modulus of all the elements in <code>x</code>; and</p> </dd> <dt><code>"2"</code></dt><dd><p>specifies the “spectral” or 2-norm, which is the largest singular value (<code><a href="svd.html">svd</a></code>) of <code>x</code>.</p> </dd> </dl> <p>The default is <code>"O"</code>. Only the first character of <code>type[1]</code> is used.</p> </td></tr> </table> <h3>Details</h3> <p>The <span class="pkg">base</span> method of <code>norm()</code> calls the Lapack function <code>dlange</code>. </p> <p>Note that the 1-, Inf- and <code>"M"</code> norm is faster to calculate than the Frobenius one. </p> <p>Unsuccessful results from the underlying LAPACK code will result in an error giving a positive error code: these can only be interpreted by detailed study of the FORTRAN code. </p> <h3>Value</h3> <p>The matrix norm, a non-negative number. </p> <h3>Source</h3> <p>Except for <code>norm = "2"</code>, the LAPACK routine <code>DLANGE</code>. </p> <p>LAPACK is from <a href="http://www.netlib.org/lapack">http://www.netlib.org/lapack</a>. </p> <h3>References</h3> <p>Anderson, E., <em>et al</em> (1994). <em>LAPACK User's Guide</em>, 2nd edition, SIAM, Philadelphia. </p> <h3>See Also</h3> <p><code><a href="kappa.html">rcond</a></code> for the (reciprocal) condition number. </p> <h3>Examples</h3> <pre> (x1 <- cbind(1, 1:10)) norm(x1) norm(x1, "I") norm(x1, "M") stopifnot(all.equal(norm(x1, "F"), sqrt(sum(x1^2)))) hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") } h9 <- hilbert(9) ## all 5 types of norm: (nTyp <- eval(formals(base::norm)$type)) sapply(nTyp, norm, x = h9) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>