https://github.com/cran/pracma
Tip revision: 3fdb68cc842f2ab3b59608f8e04d495763584f78 authored by Hans W. Borchers on 27 November 2015, 12:07:10 UTC
version 1.8.8
version 1.8.8
Tip revision: 3fdb68c
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))))
}