What is actual operation of fftshift when it appears in the nested form with FFT?
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
while "fftshift" in octave works well with small costs compared to FFT
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?
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
"fftshift" is implemented as a .m file. So you can look at its code by
calling "edit fftshift" at Octave's command prompt.