openfermion.linalg.jw_number_restrict_operator

Restrict a Jordan-Wigner encoded operator to a given particle number

sparse_operator(ndarray or sparse): Numpy operator acting on the space of n_qubits. n_electrons(int): Number of particles to restrict the operator to n_qubits(int): Number of qubits defining the total state

new_operator(ndarray or sparse): Numpy operator restricted to acting on states with the same particle number.