In the code, we begin with the cumulative-sum over the MOs, p B Iσp Iσp , as previously shown this yields the correct sign for the the creation/vacant operations. Next, the annihilating/occupied parts of the MO (assuming Ψ Iσi are sorted in ascending order along i), must be replaced by a countingup array.