The density matrix in self-consistent field theory - III. Generalizations of the theory