maxframe.tensor.left_shift#
- maxframe.tensor.left_shift(x1, x2, out=None, where=None, **kwargs)#
将整数的位向左移动。
通过在 x1 的右侧附加 x2 个 0 来将位向左移动。由于数字的内部表示是二进制格式,此操作等效于将 x1 乘以
2**x2。- 参数:
x1 (array_like of integer type) -- 输入值。
x2 (array_like of integer type) -- 要附加到 x1 的零的数量。必须为非负数。
out (Tensor, None, or tuple of Tensor and None, optional) -- 存储结果的位置。如果提供,它必须具有与输入广播兼容的形状。如果未提供或为 None,则返回一个新分配的张量。元组(只能作为关键字参数)的长度必须等于输出的数量。
where (array_like, optional) -- 值为 True 表示在该位置计算 ufunc,值为 False 表示保留输出中的值不变。
**kwargs
- 返回:
out -- 返回将 x1 的位向左移动 x2 次的结果。
- 返回类型:
tensor of integer type
参见
right_shift将整数的位向右移动。
示例
>>> import maxframe.tensor as mt
>>> mt.left_shift(5, 2).execute() 20
>>> mt.left_shift(5, [1,2,3]).execute() array([10, 20, 40])