dpnp.bitwise_invert

dpnp.bitwise_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.

Note that dpnp.bitwise_invert is an alias of dpnp.invert.

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, usm_ndarray}, optional) -- Output array to populate. Array must have the correct shape and the expected data type. Default: None.

  • 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.

dpnp.binary_repr

Return the binary representation of the input number as a string.

Examples

>>> import dpnp as np

The number 13 is represented by 00001101. The invert or bit-wise NOT of 13 is then:

>>> x = np.array([13])
>>> np.invert(x)
array([-14])
>>> np.binary_repr(-14, width=8)
'11110010'
>>> 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])