dpnp.fix

dpnp.fix(x, out=None, order='K')

Round to nearest integer towards zero.

Round an array of floats element-wise to nearest integer towards zero. The rounded values have the same data-type as the input.

For full documentation refer to numpy.fix.

Parameters:
  • x ({dpnp.ndarray, usm_ndarray}) -- Input array, expected to have a boolean or real-valued data type.

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

    Output array to populate. Array must have the correct shape and the expected data type.

    Default: None.

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

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

    Default: "K".

Returns:

out -- An array with the same dimensions and data-type as the input. If out is None then a new array is returned with the rounded values. Otherwise the result is stored there and the return value out is a reference to that array.

Return type:

dpnp.ndarray

See also

dpnp.round

Round to given number of decimals.

dpnp.rint

Round elements of the array to the nearest integer.

dpnp.trunc

Return the truncated value of the input, element-wise.

dpnp.floor

Return the floor of the input, element-wise.

dpnp.ceil

Return the ceiling of the input, element-wise.

Examples

>>> import dpnp as np
>>> np.fix(np.array(3.14))
array(3.)
>>> np.fix(np.array(3))
array(3.)
>>> a = np.array([2.1, 2.9, -2.1, -2.9])
>>> np.fix(a)
array([ 2.,  2., -2., -2.])