dpnp.modf

dpnp.modf(x, out1=None, out2=None, /, *, out=(None, None), where=True, order='K', dtype=None, subok=True, **kwargs)

Decompose each element \(x_i\) of the input array x into the fractional and the integral parts.

The fractional and integral parts are negative if the given \(x_i\) is negative.

For full documentation refer to numpy.modf.

Parameters:
  • x ({dpnp.ndarray, usm_ndarray}) -- Array of numbers to be decomposed, expected to have a real-valued floating-point data type.

  • out1 ({None, dpnp.ndarray, usm_ndarray}, optional) --

    Output array for the fractional parts to populate. Array must have the same shape as x and the expected data type.

    Default: None.

  • out2 ({None, dpnp.ndarray, usm_ndarray}, optional) --

    Output array for the integral parts to populate. Array must have the same shape as x and the expected data type.

    Default: None.

  • out (tuple of None, dpnp.ndarray, or usm_ndarray, optional) --

    A location into which the result is stored. If provided, it must be a tuple and have length equal to the number of outputs. Each provided array must have the same shape as x and the expected data type. It is prohibited to pass output arrays through out keyword when either out1 or out2 is passed.

    Default: (None, None).

  • order ({None, "C", "F", "A", "K"}, optional) --

    Memory layout of the newly output array, if parameter out is None.

    Default: "K".

Returns:

  • y1 (dpnp.ndarray) -- Fractional part of x.

  • y2 (dpnp.ndarray) -- Integral part of x.

Limitations

Parameters where, dtype and subok are supported with their default values. Keyword argument kwargs is currently unsupported. Otherwise NotImplementedError exception will be raised.

See also

dpnp.divmod

divmod(x, 1) is an equivalent to modf(x) with the return values switched, except it always has a positive remainder.

Notes

For integer input the return values are floats.

Examples

>>> import dpnp as np
>>> x = np.array([0, 3.5])
>>> np.modf(x)
(array([0. , 0.5]), array([0., 3.]))
>>> np.modf(np.array(-0.5))
(array(-0.5), array(-0.))