nlcpy.floor_divide

nlcpy.floor_divide = <ufunc 'nlcpy_floor_divide'>

Computes the element-wise floor 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.

Parameters
x1, x2array_like

x1 is a numerator array and x2 is a denominator array. 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

y = floor(x1/x2). If x1 and x2 are both scalars, this function returns the result as a 0-dimension ndarray.

See also

remainder

Computes the element-wise remainder of division.

divide

Computes the element-wise division of the inputs.

floor

Returns the floor of the input, element-wise.

ceil

Returns the ceiling of the input, element-wise.

Note

  • In Python 3.0 or later, // is the floor division operator and / is the true division operator. The floor_divide(x1,x2) function is equivalent to the floor division in Python.

Examples

>>> import nlcpy as vp
>>> vp.floor_divide(7,3)
array(2)
>>> vp.floor_divide([1., 2., 3., 4.], 2.5)
array([0., 0., 1., 1.])