qrisp.QuantumArray.all#
- QuantumArray.all(axis: int | tuple[int, ...] | None = None) QuantumArray | QuantumVariable[source]#
Performs an element-wise logical AND reduction, returning True if all elements are True.
- Parameters:
- axisint or tuple of ints, optional
Axis or axes along which a logical AND reduction is performed. The default is None, meaning that the reduction is performed over all elements.
- Returns:
- QuantumBool or QuantumArray
If axis is None, returns a single boolean value. If axis is specified, returns an array of boolean values.
- Raises:
- TypeError
If the qtype of self is not QuantumBool.
Examples
>>> import numpy as np >>> from qrisp import QuantumArray, QuantumBool >>> a_array = QuantumArray(QuantumBool(), shape=(2,2)) >>> a_array[:] = np.array([[True, True], [True, True]]) >>> print(a_array.all()) # Output: True
>>> b_array = QuantumArray(QuantumBool(), shape=(2,2)) >>> b_array[:] = np.array([[True, False], [True, True]]) >>> print(b_array.all()) # Output: False
>>> c_array = QuantumArray(QuantumBool(), shape=(2,2)) >>> c_array[:] = np.array([[True, False], [True, True]]) >>> print(c_array.all(axis=0)) # Output: [True, False]