qarp.operators.compat

openfermion interop: converters between the qarpx operator classes and openfermion’s, and openfermion’s MSB matrix layout.

openfermion is NOT a runtime dependency of qarp — the converters are for research code and notebooks that still exchange operators with openfermion (install it via the openqarp[openfermion] extra); get_sparse_operator() needs no openfermion at all, only its bit order.

qarp.operators.compat.from_openfermion(operator)[source]

Convert an openfermion FermionOperator/QubitOperator to the qarpx equivalent (exact term dict copy).

qarp.operators.compat.get_sparse_operator(operator, n_qubits=None)[source]

The matrix openfermion.get_sparse_operator would return.

scipy.sparse.csc_matrix with qubit 0 as the most-significant bit (openfermion / cirq / pennylane layout). Interop only — qarp code uses operator.sparse_matrix() (LSB, conventions §1); the two differ by qarp.endianness.msb_to_lsb_matrix(). FermionOperators go through Jordan-Wigner, matching openfermion’s jordan_wigner_sparse up to float rounding.

qarp.operators.compat.to_openfermion(operator)[source]

Convert a qarpx FermionOperator/QubitOperator to its openfermion equivalent (exact term dict copy).