jax.numpy.logical_not#

jax.numpy.logical_not(x, /)[source]#

Compute NOT bool(x) element-wise.

JAX implementation of numpy.logical_not().

Parameters:

x (ArrayLike) – input array of any dtype.

Returns:

A boolean array that computes NOT bool(x) element-wise

Return type:

Array

See also

Examples

Compute NOT x element-wise on a boolean array:

>>> x = jnp.array([True, False, True])
>>> jnp.logical_not(x)
Array([False,  True, False], dtype=bool)

For boolean input, this is equivalent to invert(), which implements the unary ~ operator:

>>> ~x
Array([False,  True, False], dtype=bool)

For non-boolean input, the input of logical_not() is implicitly cast to boolean:

>>> x = jnp.array([-1, 0, 1])
>>> jnp.logical_not(x)
Array([False,  True, False], dtype=bool)