numpy.floor_divide

numpy.floor_divide(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'floor_divide'>

Return the largest integer smaller or equal to the division of the inputs. It is equivalent to the Python // operator and pairs with the Python % (remainder), function so that a = a % b + b * (a // b) up to roundoff.

参数
x1array_like

分子。

x2array_like

分母。如果 x1.shape != x2.shape ,它们必须可以广播到公共形状(成为输出的形状)。

outndarray、none或ndarray和none的元组,可选

存储结果的位置。如果提供,它必须具有输入广播到的形状。如果未提供或没有,则返回新分配的数组。元组(只能作为关键字参数)的长度必须等于输出数。

where阵列式,可选

这种情况通过输入广播。在条件为真的位置 out 数组将被设置为ufunc结果。在其他地方 out 数组将保留其原始值。请注意,如果未初始化 out 数组是通过默认值创建的 out=None ,其中条件为False的位置将保持未初始化状态。

**kwargs

有关其他仅限关键字的参数,请参见 ufunc docs .

返回
y恩达雷

Y=地板 (x1 /` x2`)这是一个标量,如果两者都是 x1x2 是标量。

参见

remainder

剩余部分与楼层划分相辅相成。

divmod

同时进行楼层划分和余数。

divide

标准划分。

floor

将一个数字四舍五入到最接近的整数,即负无穷大。

ceil

将一个数字四舍五入到最接近的整数。

实例

>>> np.floor_divide(7,3)
2
>>> np.floor_divide([1., 2., 3., 4.], 2.5)
array([ 0.,  0.,  1.,  1.])

这个 // 运算符可用作 np.floor_divide 在星期天。

>>> x1 = np.array([1., 2., 3., 4.])
>>> x1 // 2.5
array([0., 0., 1., 1.])