qrisp.QuantumArray.__xor__#
- QuantumArray.__xor__(other: QuantumArray | QuantumVariable) QuantumArray[source]#
Performs element-wise
^(bitwise XOR) operation.- Parameters:
- otherQuantumArray | QuantumVariable
The QuantumArray or QuantumVariable to be combined with using bitwise XOR.
- 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([[False, True], [False, True]], dtype=object): 1.0}