On the calculation of exchange matrices for electronic wave functions