https://github.com/cran/pracma
Tip revision: 113add4c7a9bfd37466a9b41cf2dc060b7b87091 authored by HwB on 06 December 2012, 00:00:00 UTC
version 1.3.1
version 1.3.1
Tip revision: 113add4
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)
}