qml.math.allequal¶
- allequal(tensor1, tensor2, **kwargs)[source]¶
Returns True if two tensors are element-wise equal along a given axis.
This function is equivalent to calling
np.all(tensor1 == tensor2, **kwargs)
, but allows fortensor1
andtensor2
to differ in type.- Parameters
tensor1 (tensor_like) – tensor to compare
tensor2 (tensor_like) – tensor to compare
**kwargs – Accepts any keyword argument that is accepted by
np.all
, such asaxis
,out
, andkeepdims
. See the NumPy documentation for more details.
- Returns
If
axis=None
, a logical AND reduction is applied to all elements and a boolean will be returned, indicating if all elements evaluate toTrue
. Otherwise, a boolean NumPy array will be returned.- Return type
ndarray, bool
Example
>>> a = torch.tensor([1, 2]) >>> b = np.array([1, 2]) >>> allequal(a, b) True
code/api/pennylane.math.allequal
Download Python script
Download Notebook
View on GitHub