Adding Fourier-Identity matrices and a routine for measuring coherence.