nlcpy.left_shift
- nlcpy.left_shift = <ufunc 'nlcpy_left_shift'>
Shifts bits of an integer to the left, element-wise.
Bits are shifted to the left by appending 0 at the right of x1. Because the internal representation of integer numbers is in binary format, this operation is equivalent to multiplying .
- Parameters
- x1, x2array_like
x1 is an input array or a scalar. x2 is the number of zeros to append to x1. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output).- outndarray or None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
- wherearray_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized.- **kwargs
For other keyword-only arguments, see the section Optional Keyword Arguments.
- Returns
- yndarray
x1 with bits shifted x2 times to the left. If x1 and x2 are both scalars, this function returns the result as a 0-dimension ndarray.
参考
right_shift
Shifts bits of an integer to the right, element-wise.
注釈
If the values of x2 are greater equal than the bit-width of x1, this function returns zero.
If the values of x2 are negative numbers, undefined values are returned.
Examples
>>> import nlcpy as vp >>> vp.left_shift(5, 2) array(20) >>> vp.left_shift(5, [1,2,3]) array([10, 20, 40])