Root-of-unity filter (source code)

= Root-of-unity filter

For $\omega=e^{2\pi i/N}$,
$$
\sum_{y=0}^{N-1}\omega^{my}
=\begin{cases}N,&N\mid m,\\0,&N\nmid m.\end{cases}
$$
This is the finite <geometric series> identity and expresses orthogonality of the characters of $\mathbb Z_N$.