Skip to content

Add QubitSparsePauli.equal_indices checking if another qubit sparse pauli is non-trival on the same qubits #15883

Description

@DanPuzzuoli

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    mod: quantum infoRelated to the Quantum Info module (States & Operators)type: feature requestNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Ready

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions