Canonical purification of the density matrix in electronic-structure theory | Synapse