qrisp.QuantumArray.__gt__#
- QuantumArray.__gt__(other: QuantumArray | QuantumVariable | 'ArrayLike') QuantumArray[source]#
Performs element-wise
>comparison.- Parameters:
- otherQuantumArray | QuantumVariable | ArrayLike
The array or scalar to be compared to. If an array is provided, it must have the same shape as the original QuantumArray. If a scalar is provided, it will be compared with each element of the QuantumArray.
- Returns:
- QuantumArray
A new QuantumArray of QuantumBools containing the result of element-wise
>.
- Raises:
- TypeError
If the qtypes of self and other are incompatible for comparison.
- ValueError
If other is an array (QuantumArray or numpy/jax array) and its shape does not match the shape of self.
Examples
Compare two QuantumArrays of QuantumFloats for greater-than:
>>> import numpy as np >>> from qrisp import QuantumArray, QuantumFloat >>> a_array = QuantumArray(QuantumFloat(2), shape=(2,2)) >>> b_array = QuantumArray(QuantumFloat(2), shape=(2,2)) >>> a_array[:] = np.array([[0, 1], [2, 3]]) >>> b_array[:] = np.array([[0, 3], [2, 1]]) >>> r_array = a_array > b_array >>> print(r_array) # {OutcomeArray([[False, False], [False, True]], dtype=object): 1.0}
Compare a QuantumArray of QuantumFloats to a numpy array:
>>> import numpy as np >>> from qrisp import QuantumArray, QuantumFloat >>> a_array = QuantumArray(QuantumFloat(2), shape=(2,2)) >>> a_array[:] = np.array([[0, 1], [2, 3]]) >>> r_array = a_array > np.array([[0, 3], [2, 1]]) >>> print(r_array) # {OutcomeArray([[False, False], [False, True]], dtype=object): 1.0}