braintools.spike.bitwise_or

Contents

braintools.spike.bitwise_or#

braintools.spike.bitwise_or(x, y)#

Perform a bitwise OR operation on spike tensors.

This function computes the OR operation between two spike tensors. The OR operation is implemented using the formula x + y - x * y, which is equivalent to the OR operation for binary values.

Parameters:
  • x (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – The first input spike tensor.

  • y (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – The second input spike tensor.

Returns:

The element-wise OR of the inputs, with their broadcast shape.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | Quantity

See also

bitwise

Dispatch to a bitwise operation by name.

bitwise_and, bitwise_xor, bitwise_not

Notes

This operation assumes that the input tensors contain binary (0 or 1) values. For non-binary inputs, the behavior may not correspond to a true bitwise OR. Boolean inputs give a boolean result (computed with the logical functions); numeric inputs use the arithmetic formula, which keeps the dtype and stays differentiable for surrogate-gradient spikes.

Examples

>>> import jax.numpy as jnp
>>> import braintools
>>> x = jnp.array([0, 0, 1, 1])
>>> y = jnp.array([0, 1, 0, 1])
>>> braintools.spike.bitwise_or(x, y)
Array([0, 1, 1, 1], dtype=int32)
>>>
>>> braintools.spike.bitwise_or(x.astype(bool), y.astype(bool))
Array([False,  True,  True,  True], dtype=bool)