spike_bitwise

Contents

spike_bitwise#

class braintools.spike_bitwise(x, y, op)#

Perform bitwise operations on spike tensors.

This function applies various bitwise operations on spike tensors based on the specified operation. It supports ‘or’, ‘and’, ‘iand’, ‘xor’, and ‘ixor’ operations.

Parameters:
  • x (Tensor) – The first input spike tensor.

  • y (Tensor) – The second input spike tensor.

  • op (str) – A string indicating the bitwise operation to perform. Supported operations are ‘or’, ‘and’, ‘iand’, ‘xor’, and ‘ixor’.

Returns:

The result of the bitwise operation applied to the input tensors.

Return type:

Tensor

Raises:

NotImplementedError – If an unsupported bitwise operation is specified.

Note

The function uses the following mathematical expressions for different operations:

\[\begin{split}\begin{array}{ccc} \hline \text { Mode } & \text { Expression for } \mathrm{g}(\mathrm{x}, \mathrm{y}) & \text { Code for } \mathrm{g}(\mathrm{x}, \mathrm{y}) \\ \hline \text { ADD } & x+y & x+y \\ \text { AND } & x \cap y & x \cdot y \\ \text { IAND } & (\neg x) \cap y & (1-x) \cdot y \\ \text { OR } & x \cup y & (x+y)-(x \cdot y) \\ \hline \end{array}\end{split}\]