R/Lnorm.R

Defines functions Lnorm

Documented in Lnorm

#'
#' L-p norm of a given complex vector
#'
#'@author Mehmet Suzen
#'@param X, a complex vector, can be real too.
#'@param p, norm value
#'@return L-p norm of the complex vector
#'
Lnorm <- function(X, p) {
  LX <- Mod(X)
  if(p>0 & p <Inf) {
    LX <- sum(LX^p)^(1.0/p)
  }
  if(p == Inf) return(max(LX))
  if(p == 0) return(length(which(LX==0)))
  return(LX)
}

Try the R1magic package in your browser

Any scripts or data that you put into this service are public.

R1magic documentation built on Aug. 27, 2023, 5:07 p.m.