# norm

##### Compute the Norm of a Matrix

Computes a matrix norm of `x`

using LAPACK. The norm can be
the one (`"O"`

) norm, the infinity (`"I"`

) norm, the
Frobenius (`"F"`

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

) among
elements of a matrix, or the “spectral” or `"2"`

-norm, as
determined by the value of `type`

.

- Keywords
- math

##### Usage

`norm(x, type = c("O", "I", "F", "M", "2"))`

##### Arguments

- x
numeric matrix; note that packages such as Matrix define more

`norm()`

methods.- type
character string, specifying the

*type*of matrix norm to be computed. A character indicating the type of norm desired.`"O"`

,`"o"`

or`"1"`

specifies the

**o**ne norm, (maximum absolute column sum);`"I"`

or`"i"`

specifies the

**i**nfinity norm (maximum absolute row sum);`"F"`

or`"f"`

specifies the

**F**robenius norm (the Euclidean norm of`x`

treated as if it were a vector);`"M"`

or`"m"`

specifies the

**m**aximum modulus of all the elements in`x`

; and`"2"`

specifies the “spectral” or 2-norm, which is the largest singular value (

`svd`

) of`x`

.

The default is

`"O"`

. Only the first character of`type[1]`

is used.

##### Details

The base method of `norm()`

calls the Lapack function
`dlange`

.

Note that the 1-, Inf- and `"M"`

norm is faster to calculate than
the Frobenius one.

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.

##### Value

The matrix norm, a non-negative number.

##### References

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

##### See Also

`rcond`

for the (reciprocal) condition number.

##### Examples

`library(base)`

```
# NOT RUN {
(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)
# }
```

*Documentation reproduced from package base, version 3.6.1, License: Part of R 3.6.1*