norm {base} | R Documentation |
Computes a matrix norm of x
using Lapack. The norm can be
the one norm, the infinity norm, the Frobenius norm, or the maximum
modulus among elements of a matrix, as determined by the value of
type
.
norm(x, type = c("O", "I", "F", "M"))
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" . Only the first character of
type[1] is used. |
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.
The matrix norm, a non-negative number.
Anderson, E., et al. (1994). LAPACK User's Guide, 2nd edition, SIAM, Philadelphia.
rcond
for the (reciprocal) condition number.
(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 4 types of norm: (nTyp <- eval(formals(base::norm)$type)) sapply(nTyp, norm, x=h9)