loading...

Fast version of logarithmic and exponential functions (when vector size >= 50000). log_() computes the natural logarithm of x (base e by default), log2_() computes the base 2 logarithm, log10_() computes the base 10. log1p_() computes log(1 + x) accurately even for small x.

exp_() computes the exponential function. expm1_() computes exp(x) - 1 accurately even for small x.

log10_(x, para = 50000L)

log2_(x, para = 50000L)

log1p_(x, para = 50000L)

exp_(x, para = 50000L)

expm1_(x, para = 50000L)

log_(x, base = 2.71828182845905, para = 50000L)

Arguments

x

vector of numeric values

para

the minimum length of x to use parallel computation (50000 by default)

base

the base of the logarithm (e = exp(1) by default)

Value

A numeric vector, matrix, or data frame with the transformed values.

Details

They are not generic functions and do not process factor, Date, POSIXt, difftime, complex, or S4 objects (use base R equivalent function instead). Data frames are processed column-wise, providing each column is compatible. All attributes are preserved.

Examples

log_(1:5)
#> [1] 0.0000000 0.6931472 1.0986123 1.3862944 1.6094379
log_(1:5, base = 2.5)
#> [1] 0.0000000 0.7564708 1.1989778 1.5129416 1.7564708