https://github.com/cran/pracma
Revision b5e4bf28fcba9f5eaffbeecfb0bc307452d074ee authored by Hans W. Borchers on 01 November 2014, 00:00:00 UTC, committed by Gabor Csardi on 01 November 2014, 00:00:00 UTC
1 parent d57c14d
Tip revision: b5e4bf28fcba9f5eaffbeecfb0bc307452d074ee authored by Hans W. Borchers on 01 November 2014, 00:00:00 UTC
version 1.7.7
version 1.7.7
Tip revision: b5e4bf2
cond.R
##
## c o n d . R Matrix Condition
##
cond <- function(M, p = 2) {
if (length(M) == 0)
return(0)
if (!is.numeric(M))
stop("Argument 'M' must be a numeric matrix.")
if (is.vector(M))
M <- matrix(c(M), nrow = length(M), ncol = 1)
if (length(M) == 0) return(c())
if (ncol(M) != nrow(M) && p != 2)
stop("Matrix 'M' must be square if p = 2.")
if (p == 2) {
s <- svd(M)$d
cnd <- if (any(s == 0)) Inf else max(s) / min(s)
} else {
stop("At the moment, p-norms other than p = 2 are not implemented.")
#cnd <- norm(M, p) * norm(inv(M), p)
}
return(cnd)
}
Computing file changes ...