dpnp.bitwise_invert

dpnp.bitwise_invert = <DPNPUnaryFunc 'invert'>

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 an integer or boolean data type.

out{None, dpnp.ndarray, usm_ndarray, tuple of ndarray}, optional

Output array to populate. Array must have the correct shape and the expected data type. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

Default: None.

order{None, "C", "F", "A", "K"}, optional

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

Default: "K".

Returns:
outdpnp.ndarray

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

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])