pow2: MATLAB pow2 function

View source: R/pow2.R

pow2R Documentation

MATLAB pow2 function

Description

Power with base 2.

Usage

pow2(f, e)

Arguments

f

numeric vector of factors

e

numeric vector of exponents for base 2

Details

Computes the expression f * 2^e for corresponding elements of f and e. If e is missing, it sets e to f and f to 1. Imaginary parts of complex values are ignored unless e is missing.

Value

Returns numeric vector constructed as described above.

Author(s)

H. Borchers hwborchers@googlemail.com, P. Roebuck proebuck1701@gmail.com

See Also

nextpow2

Examples

pow2(c(0, 1, 2, 3))               # 1 2 4 8
pow2(c(0, -1, 2, 3), c(0,1,-2,3)) # 0.0 -2.0  0.5 24.0
pow2(1i)                          # 0.7692389+0.6389613i

# For IEEE arithmetic...
pow2(1/2, 1)                      # 1
pow2(pi/4, 2)                     # pi
pow2(-3/4, 2)                     # -3
pow2(1/2, -51)                    # .Machine$double.eps
pow2(1/2, -1021)                  # .Machine$double.xmin

matlab documentation built on June 2, 2022, 1:09 a.m.