log2¶
-
log2(x, out=None, **kwargs)¶ Base-2 logarithm of x.
Parameters: - x : ndarray or scalar
Input values.
- out : ndarray or None
A location into which the result is stored. If provided, it must have the same shape and type as the input. If not provided or None, a freshly-allocated array is returned.
Returns: - y : ndarray
The logarithm base two of x, element-wise. This is a scalar if x is a scalar.
Notes
This function differs from the original numpy.log2 in the following way(s): - only ndarray or scalar is accpted as valid input, tuple of ndarray is not supported - broadcasting to out of different shape is currently not supported - when input is plain python numerics, the result will not be stored in the out param
Examples
>>> x = np.array([0, 1, 2, 2**4]) >>> np.log2(x) array([-inf, 0., 1., 4.])