braintools.spike.bitwise_and

Contents

braintools.spike.bitwise_and#

braintools.spike.bitwise_and(x, y)#

Perform a bitwise AND operation on spike tensors.

This function computes the AND operation between two spike tensors. The AND operation is equivalent to element-wise multiplication 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 AND 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_or, bitwise_iand

Notes

This operation is implemented using element-wise multiplication (x * y), which is equivalent to the AND operation for binary values. 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_and(x, y)
Array([0, 0, 0, 1], dtype=int32)
>>>
>>> # A boolean mask mixed with a float tensor takes the float dtype.
>>> braintools.spike.bitwise_and(x.astype(bool), y.astype(jnp.float32))
Array([0., 0., 0., 1.], dtype=float32)