mxnet.np.true_divide¶
-
true_divide
(x1, x2, out=None)¶ Returns a true division of the inputs, element-wise.
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.
- Parameters
x1 (ndarray or scalar) – Dividend array.
x2 (ndarray or scalar) – Divisor array.
out (ndarray) – 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.
- Returns
out (ndarray or scalar) – This is a scalar if both x1 and x2 are scalars.
.. note:: – This operator now supports automatic type promotion. The resulting type will be determined according to the following rules:
If both inputs are of floating number types, the output is the more precise type.
If only one of the inputs is floating number type, the result is that type.
If both inputs are of integer types (including boolean), the output is of float32 or float64 type, which depends on your current default dtype. When npx.is_np_default_dtype() returns False, default dtype is float32; When npx.is_np_default_dtype() returns True, default dtype is float64.
Examples
>>> x = np.arange(5) >>> np.true_divide(x, 4) array([0. , 0.25, 0.5 , 0.75, 1. ])