```Allen,

Probably it needs to work in n-dimensions, like the existing
np.fft.fftshift function does, with an optional axis=tuple parameter. I
recall that fftshift is just an array indexing trick?  It would be helpful
to see what's faster, two fftshifts and a edge padding or your
inter-padding.  Probably it's faster to make a new zeros array of the
appropriate padded size and do 2*ndim copies?```
```
Robert

On Wed, May 25, 2016 at 9:35 PM, Allen Welkie <allen.wel...@gmail.com>
wrote:

> I'd like to get some feedback on my [pull request](
> https://github.com/numpy/numpy/pull/7593).
>
> inserting zeros where the highest frequencies would be. This is necessary
> because the padding that `ifft` does simply inserts zeros at the end of the
> array. But because of the way the spectrum is laid out, this changes which
> bins represent which frequencies and in general messes up the result of
> `ifft`. If you pad with the proposed `ifftpad` function, the zeros will be
> inserted in the middle of the spectrum and the time signal that results
> from `ifft` will be an interpolated version of the unpadded time signal.
> See the discussion in [issue #1346](
> https://github.com/numpy/numpy/issues/1346).
>
> The following is a script to demonstrate what I mean:
>
> ```
> import numpy
> from numpy import concatenate, zeros
> from matplotlib import pyplot
>
>     """ A copy of the proposed `ifftpad` function. """
>     spectrum = concatenate((a[:len(a) // 2],
>                             zeros(n - len(a)),
>                             a[len(a) // 2:]))
>     if scale:
>         spectrum *= (n / len(a))
>     return spectrum
>
> def plot_real(signal, label):
>     time = numpy.linspace(0, 1, len(signal) + 1)[:-1]
>     pyplot.plot(time, signal.real, label=label)
>
> def main():
>     spectrum = numpy.zeros(10, dtype=complex)
>     spectrum[-1] = 1 + 1j
>
>     signal = numpy.fft.ifft(spectrum)
>
>
>     pyplot.legend()
>     pyplot.show()
>
>
> if __name__ == '__main__':
>     main()
> ```
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>

--
Robert McLeod, Ph.D.
Center for Cellular Imaging and Nano Analytics (C-CINA)
Biozentrum der Universität Basel
Mattenstrasse 26, 4058 Basel
Work: +41.061.387.3225
robert.mcl...@unibas.ch
robert.mcl...@bsse.ethz.ch <robert.mcl...@ethz.ch>
robbmcl...@gmail.com
```
```_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion
```