dpnp.invert

dpnp.invert(x, out=None, where=True, order='K', dtype=None, subok=True, **kwargs)

Inverts (flips) each bit for each element x_i of the input array x.

For full documentation refer to numpy.invert.

Parameters:
  • x ({dpnp.ndarray, usm_ndarray}) – Input array, expected to have integer or boolean data type.

  • out ({None, dpnp.ndarray}, optional) – Output array to populate. Array must have the correct shape and the expected data type.

  • order ({"C", "F", "A", "K"}, optional) – Memory layout of the newly output array, if parameter out is None. Default: “K”.

Returns:

out – An array containing the element-wise results. The data type of the returned array is same as the data type of the input array.

Return type:

dpnp.ndarray

Limitations

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

See also

dpnp.bitwise_and

Compute the bit-wise AND of two arrays element-wise.

dpnp.bitwise_or

Compute the bit-wise OR of two arrays element-wise.

dpnp.bitwise_xor

Compute the bit-wise XOR of two arrays element-wise.

dpnp.logical_not

Compute the truth value of NOT x element-wise.

Examples

>>> import dpnp as np
>>> x = np.array([13])
>>> np.invert(x)
-14
>>> a = np.array([True, False])
>>> np.invert(a)
array([False,  True])

The ~ operator can be used as a shorthand for invert on dpnp.ndarray.

>>> ~a
array([False,  True])