pow.int | R Documentation |
Fast exponentiation when the exponent is an integer.
pow.int(x, n) x %^% n
x |
a numeric vector giving the base. |
n |
an integer vector giving the exponent. |
A numeric vector.
This function is just a wrapper around R_pow_di
in the Rmath
library.
Jonathan Debove
3 %^% 12L # Basic tests x <- runif(10) n <- as.integer(runif(length(x), 0, 100)) stopifnot(all.equal(pow.int(x, n), x ^ n)) stopifnot(all.equal(pow.int(x[1], n), x[1] ^ n)) stopifnot(all.equal(pow.int(x, n[1]), x ^ n[1])) stopifnot(all.equal(pow.int(x[1:2], n), x[1:2] ^ n)) stopifnot(all.equal(pow.int(x, n[1:2]), x ^ n[1:2]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.