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 for tensor1 and tensor2 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 as axis, out, and keepdims. 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 to True. 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

Contents

Using PennyLane

Release news

Development

API

Internals