What should we add?
This is pretty trivial, the function should have the same behaviour as the python code:
def equal_indices(self, other: QubitSparsePauli) -> bool:
return np.array_equal(self.indices, other.indices)
Despite the above being pretty trivial, it is surprisingly slow, which I think is due to the python property QubitSparsePauli.indices needing to create a numpy array from the rust data. The goal with this method is to do the comparison in rust and then only need to pass a bool to python.
Further, it may be useful to have a method like this on QubitSparsePauliList, which could either do a pairwise comparison, i.e. equivalent to x.equal_indices(y) for x, y in zip(self, other), or possibly return a list of index pairs for which x.equal_indices(y) is true for x, y in product(self, other).
What should we add?
This is pretty trivial, the function should have the same behaviour as the python code:
Despite the above being pretty trivial, it is surprisingly slow, which I think is due to the python property
QubitSparsePauli.indicesneeding to create a numpy array from the rust data. The goal with this method is to do the comparison in rust and then only need to pass a bool to python.Further, it may be useful to have a method like this on
QubitSparsePauliList, which could either do a pairwise comparison, i.e. equivalent tox.equal_indices(y) for x, y in zip(self, other), or possibly return a list of index pairs for whichx.equal_indices(y)is true forx, y in product(self, other).