https://github.com/cran/pracma
Tip revision: c1688b374d201c13fb40b4dda2d2a89e34b94ec6 authored by Hans W. Borchers on 23 January 2021, 09:10:02 UTC
version 2.3.3
version 2.3.3
Tip revision: c1688b3
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))))
}