improved the fourier matrix calculation