https://github.com/cran/pracma
Tip revision: 26e049d70b4a1c237987e260cba68f6a9413736c authored by Hans W. Borchers on 09 April 2019, 04:10:07 UTC
version 2.2.5
version 2.2.5
Tip revision: 26e049d
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)
}