Skip to content

Instantly share code, notes, and snippets.

@marmakoide
Last active March 31, 2020 09:19
Show Gist options
  • Save marmakoide/d8925a5ed149ce83f37ddb41c38edd8b to your computer and use it in GitHub Desktop.
Save marmakoide/d8925a5ed149ce83f37ddb41c38edd8b to your computer and use it in GitHub Desktop.
Rotation of 2d DFT coefficients, avoiding computing a DFT by directly transforming the DFT coefficients
import numpy
def rot180_fft_2d(X, N):
I = numpy.repeat([numpy.arange(N)], N, axis = 0)
K = numpy.exp((2 * numpy.pi / N) * (I + I.T) * 1j)
return K * numpy.conj(X)
def rot180_rfft_2d(X, N):
I = numpy.repeat([numpy.arange(N)], N, axis = 0)
K = numpy.exp((2 * numpy.pi / N) * (I + I.T) * 1j)[:,:N // 2 + 1]
return K * numpy.conj(X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment