nlcpy.true_divide = <ufunc 'nlcpy_true_divide'>

Computes the element-wise division of the inputs.

Instead of the Python traditional 'floor division', this returns a true division. True division adjusts the output type to present the best answer, regardless of input types.

x1, x2array_like

x1 is a dividend array and x2 is a divisor 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.


For other keyword-only arguments, see the section Optional Keyword Arguments.


The result that x1 is divided by x2 for each element. If x1 and x2 are both scalars, this function returns the result as a 0-dimension ndarray.


  • If the values of x2 are zero, the corresponding return values become nan (not inf) due to performance reasons.

  • Equivalent to x1 / x2 in terms of array broadcasting.

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


>>> import nlcpy as vp
>>> x = vp.arange(5)
>>> vp.true_divide(x, 4)
array([0.  , 0.25, 0.5 , 0.75, 1.  ])
>>> x/4
array([0.  , 0.25, 0.5 , 0.75, 1.  ])
>>> x//4
array([0, 0, 0, 0, 1])