qrisp.QuantumArray.any#

QuantumArray.any(axis: int | tuple[int, ...] | None = None) QuantumArray | QuantumVariable[source]#

Performs an element-wise logical OR reduction, returning True if any element is True.

Parameters:
axisint or tuple of ints, optional

Axis or axes along which a logical OR 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([[False, False], [False, False]])
>>> print(a_array.any())  # Output: False
>>> b_array = QuantumArray(QuantumBool(), shape=(2,2))
>>> b_array[:] = np.array([[True, False], [False, False]])
>>> print(b_array.any())  # Output: True
>>> c_array = QuantumArray(QuantumBool(), shape=(2,2))
>>> c_array[:] = np.array([[True, False], [False, False]])
>>> print(c_array.any(axis=0))  # Output: [True, False]