
Last chance! 50% off unlimited learning
Sale ends in
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
.
norm(x, type = c("O", "I", "F", "M", "2"))
norm()
methods."O"
, "o"
or "1"
"I"
or "i"
"F"
or "f"
x
treated as if it were a vector);
"M"
or "m"
x
; and
"2"
svd
) of x
.
The default is "O"
. Only the first character of
type[1]
is used.
norm = "2"
, the LAPACK routine DLANGE
. LAPACK is from http://www.netlib.org/lapack.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.
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 5 types of norm:
(nTyp <- eval(formals(base::norm)$type))
sapply(nTyp, norm, x = h9)
Run the code above in your browser using DataLab