Construction of the hamiltonian matrix in large configuration interaction calculations