qrisp.QuantumArray.__and__#

QuantumArray.__and__(other: QuantumArray | QuantumVariable) QuantumArray[source]#

Performs element-wise & (bitwise AND) operation.

Parameters:
otherQuantumArray | QuantumVariable

The QuantumArray or QuantumVariable to be combined with using bitwise AND.

Returns:
QuantumArray

A new QuantumArray of QuantumBools containing the result of element-wise &.

Raises:
TypeError

If the qtypes of self and other are not QuantumBool.

ValueError

If other is an array (QuantumArray or numpy/jax array) and its shape does not match the shape of self.

Examples

>>> import numpy as np
>>> from qrisp import QuantumArray, QuantumBool
>>> a_array = QuantumArray(QuantumBool(), shape=(2,2))
>>> b_array = QuantumArray(QuantumBool(), shape=(2,2))
>>> a_array[:] = np.array([[True, False], [False, True]])
>>> b_array[:] = np.array([[True, True], [False, False]])
>>> r_array = a_array & b_array
>>> print(r_array)
# {OutcomeArray([[True, False], [False, False]], dtype=object): 1.0}