Fourier PCA code from http://arxiv.org/abs/1306.5825