Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K
JAX  documentation - Home

jax.numpy.left_shift

Contents

jax.numpy.left_shift#

jax.numpy.left_shift(x,y,/)[source]#

Shift bits ofx to left by the amount specified iny, element-wise.

JAX implementation ofnumpy.left_shift.

Parameters:
  • x (ArrayLike) – Input array, must be integer-typed.

  • y (ArrayLike) – The amount of bits to shift each element inx to the left, only acceptsinteger subtypes.x andy must either have same shape or be broadcastcompatible.

Returns:

An array containing the left shifted elements ofx by the amount specifiediny, with the same shape as the broadcasted shape ofx andy.

Return type:

Array

Note

Left shiftingx byy is equivalent tox*(2**y) within thebounds of the dtypes involved.

See also

Examples

>>>defprint_binary(x):...return[bin(int(val))forvalinx]
>>>x1=jnp.arange(5)>>>x1Array([0, 1, 2, 3, 4], dtype=int32)>>>print_binary(x1)['0b0', '0b1', '0b10', '0b11', '0b100']>>>x2=1>>>result=jnp.left_shift(x1,x2)>>>resultArray([0, 2, 4, 6, 8], dtype=int32)>>>print_binary(result)['0b0', '0b10', '0b100', '0b110', '0b1000']
>>>x3=4>>>print_binary([x3])['0b100']>>>x4=jnp.array([1,2,3,4])>>>result1=jnp.left_shift(x3,x4)>>>result1Array([ 8, 16, 32, 64], dtype=int32)>>>print_binary(result1)['0b1000', '0b10000', '0b100000', '0b1000000']
Contents

[8]ページ先頭

©2009-2025 Movatter.jp