# [Scipy-tickets] [SciPy] #1232: Support fft normalization once added to numpy

SciPy Trac scipy-tickets@scipy....
Thu Jul 15 01:47:39 CDT 2010

```#1232: Support fft normalization once added to numpy
-----------------------------------------------+----------------------------
Reporter:  dgoldsmith                         |       Owner:  somebody
Type:  enhancement                        |      Status:  new
Priority:  normal                             |   Milestone:  0.9.0
Component:  Other                              |     Version:  0.7.0
Keywords:  fft normalization keyword unitary  |
-----------------------------------------------+----------------------------

Comment(by cycomanic):

I think you misunderstood. If you do the FFT algorithm without
normalization:

fft(ifft(X))==len(X)*X

A lot of fft implementations therefore implicitly redefine ifft (numpy
does this, matlab as well):
def new_ifft(X):
return ifft(X)/len(X)

For unitary operation you need to redefine both ifft and fft
def new_ifft(X):
return ifft(X)/sqrt(len(X))
def new_fft(X):
return fft(X)/sqrt(len(X))

However because often if you use ffts/iffts you will do some calculation
later, so it's numerically a (little) more efficient to do the
normalization together with any other calculation you do. Therefore you
want both fft and ifft to have no normalization (fftw does it this way).

So in order for the new functions to not break existing behaviour they
should look like this:
def newfft(X, ... , norm=None):
F = fft(X)
if norm == 'n':
return F/len(X)
elif norm == 'unitary':
return F/sqrt(len(X))
else
return F
def newifft(X, ... , norm='n'):
I = ifft(X)
if norm == 'n':
return I/len(X)
elif norm == 'unitary':
return I/sqrt(len(X))
else:
return I

Hope that clears thinks up.

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1232#comment:8>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
```