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_operatorwould return.scipy.sparse.csc_matrixwith qubit 0 as the most-significant bit (openfermion / cirq / pennylane layout). Interop only — qarp code usesoperator.sparse_matrix()(LSB, conventions §1); the two differ byqarp.endianness.msb_to_lsb_matrix(). FermionOperators go through Jordan-Wigner, matching openfermion’sjordan_wigner_sparseup to float rounding.