https://github.com/cran/pracma
Tip revision: 708a2ad382a163d1eef5af0665e3ae2aad200ced authored by HwB on 21 March 2013, 00:00:00 UTC
version 1.4.5
version 1.4.5
Tip revision: 708a2ad
norm.R
##
## n o r m . R Vector Norm
##
Norm <- function(x, p=2) {
stopifnot(is.numeric(x) || is.complex(x),
is.numeric(p), length(p) == 1)
if (p > -Inf && p < Inf) sum(abs(x)^p)^(1/p)
else if (p == Inf) max(abs(x))
else if (p == -Inf) min(abs(x))
else return(NULL)
}