norm-methods | R Documentation |

Computes a matrix norm of `x`

, using Lapack for dense matrices.
The norm can be the one (`"O"`

, or `"1"`

) norm, the
infinity (`"I"`

) norm, the Frobenius (`"F"`

) norm,
the maximum modulus (`"M"`

) among elements of a matrix, or the
spectral norm or 2-norm (`"2"`

), as determined by the value of
`type`

.

```
norm(x, type, ...)
```

`x` |
a real or complex matrix. |

`type` |
A character indicating the type of norm desired. `"O"` ,`"o"` or`"1"` specifies the one norm, (maximum absolute column sum); `"I"` or`"i"` specifies the infinity norm (maximum absolute row sum); `"F"` or`"f"` specifies the Frobenius norm (the Euclidean norm of `x` treated as if it were a vector);`"M"` or`"m"` specifies the maximum modulus of all the elements in `x` ; and`"2"` specifies the “spectral norm” aka “2-norm”, which is the largest singular value ( `svd` ) of`x` .
The default is |

`...` |
further arguments passed to or from other methods. |

For dense matrices, the methods eventually call the Lapack functions
`dlange`

, `dlansy`

, `dlantr`

, `zlange`

,
`zlansy`

, and `zlantr`

.

A numeric value of class `"norm"`

, representing the quantity
chosen according to `type`

.

Anderson, E., et al. (1994).
*LAPACK User's Guide,*
2nd edition, SIAM, Philadelphia.

`onenormest()`

, an *approximate* randomized estimate
of the 1-norm condition number, efficient for large sparse matrices.

The `norm()`

function from **R**'s base package.

```
x <- Hilbert(9)
norm(x)# = "O" = "1"
stopifnot(identical(norm(x), norm(x, "1")))
norm(x, "I")# the same, because 'x' is symmetric
allnorms <- function(x) {
## norm(NA, "2") did not work until R 4.0.0
do2 <- getRversion() >= "4.0.0" || !anyNA(x)
vapply(c("1", "I", "F", "M", if(do2) "2"), norm, 0, x = x)
}
allnorms(x)
allnorms(Hilbert(10))
i <- c(1,3:8); j <- c(2,9,6:10); x <- 7 * (1:7)
A <- sparseMatrix(i, j, x = x) ## 8 x 10 "dgCMatrix"
(sA <- sparseMatrix(i, j, x = x, symmetric = TRUE)) ## 10 x 10 "dsCMatrix"
(tA <- sparseMatrix(i, j, x = x, triangular= TRUE)) ## 10 x 10 "dtCMatrix"
(allnorms(A) -> nA)
allnorms(sA)
allnorms(tA)
stopifnot(all.equal(nA, allnorms(as(A, "matrix"))),
all.equal(nA, allnorms(tA))) # because tA == rbind(A, 0, 0)
A. <- A; A.[1,3] <- NA
stopifnot(is.na(allnorms(A.))) # gave error
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.