# What is actual operation of fftshift when it appears in the nested form with FFT? Classic List Threaded 3 messages Reply | Threaded
Open this post in threaded view
|

## What is actual operation of fftshift when it appears in the nested form with FFT?

 Hello, I try to do the computation consisting of FFTs and some other parts. Although FFTs, which may be effectively computed by Octave, are dominant parts in the computation, the cost of other computations, which are not so suitable for Octave or matlab, are not negligibly small. Hence I am trying to implement also by Fortran. However, in the case of Fortran, shifting of arrays ("cshift" in fortran) associated with FFT is very slow (half of total cpu time is used in cshift!), while "fftshift" in octave works well with small costs compared to FFT itself. My question is that, when fftshift appears in the nested form with FFT as   Y = fftshift(fft(fftshift(X))), what is actual operation of fftshift? Does Octave literally do the shift twice? If so, is the scheme very special and elaborate one? (because standard "cshift" in fortran is very slow in this case) Or does Octave do the computation   Y = fftshift(fft(fftshift(X))) with other methods that actually do not use shifts? Sincerely yours, Masanari HATTORI -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Reply | Threaded
Open this post in threaded view
|

## Re: What is actual operation of fftshift when it appears in the nested form with FFT?

 As far as I can tell, Octave doesn't combine functions but calls them one after the other. So in your example, Octave would call fftshift with the parameter X. Next, it would call fft with the result of this fftshift. As the last step, it would call fftshift again with the result of the fft and assign that result to Y. "fftshift" is implemented as a .m file. So you can look at its code by calling "edit fftshift" at Octave's command prompt. HTH Markus -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Reply | Threaded
Open this post in threaded view
|

## Re: What is actual operation of fftshift when it appears in the nested form with FFT?

 Dear Markus, Understood. Thank you very much. Sincerely yours, Masanari HATTORI -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html