title: How to write fftshift and ifftshift in R?
body: <p>In <code>numpy</code>, we have the following functions :</p>
  
  <pre><code>import numpy
  from numpy.fft import fft2, ifft2, fftshift, ifftshift
  </code></pre>
  
  <p>I would like to rewrite these functions in R. <code>fft</code> in R works just as <code>fft</code> or <code>fft2</code> in python. Also for <code>ifft2</code>, we have to do <code>fft(,inverse=T)</code></p>
  
  <p>Now I would like to know how to rewrite the <code>fftshift</code> and <code>ifftshift</code> functions (for matrices), efficiently in R.</p>