https://github.com/cran/pracma
Tip revision: 392ae21a013fb3f518e8f9eb8efb458a55a2eca2 authored by HwB on 09 April 2011, 00:00:00 UTC
version 0.3-0
version 0.3-0
Tip revision: 392ae21
nextpow2.R
###
### NEXTPOW2.R Next higher power of 2
###
nextpow2 <- function(x) {
if (is.null(x) || length(x) == 0) return(c())
if (!is.numeric(x) && !is.complex(x))
stop("Argument 'x' must be a numeric/complex vector/matrix.")
x[x == 0] <- 1
return(ceiling(log2(abs(x))))
}