[Numpy-discussion] Numpy FFT normalization options issue (addition of new option)

2020-06-04 Thread cvav
Issue #16126: https://github.com/numpy/numpy/issues/16126
PR #16476: https://github.com/numpy/numpy/pull/16476
numpy.fft docs (v1.18):
https://numpy.org/doc/1.18/reference/routines.fft.html

Hello all, 
I was advised to write on the numpy mailing list, after this week's
community meeting led to some general discussions on the normalization
schemes used in the FFT functions.

My post has to do with issue #16126, which asks for the addition of a new
option for the "norm" argument for the FFT functions; "norm" controls the
way the forward (direct) and backward (inverse) transforms are normalized,
and the two currently supported options are "norm=None" (default) and
"norm=ortho". The "ortho" option uses the orthonormal Fourier basis
functions, which translates to both the forward and backward transforms
being scaled by 1/sqrt(n), where n is the number of Fourier modes (and data
points). The default "None" option scales the forward transform by 1
(unscaled) and the backward by 1/n. 

The new added option, called for now "norm=inverse", is the exact opposite
of the default option; i.e. it scales the forward transform by 1/n and the
backward by 1. In terms of using the FFT for spectral methods or
approximation problems, these are the three scaling schemes one encounters;
the transform itself is the same, with only a constant factor being the
difference. But having all three scaling options built in the fft and ifft
functions makes the code cleaner and it's easier to stay consistent.

I've submitted a PR for this change, and would be happy to get comments and
feedback on the implementation and anything else that hasn't been
considered. Thanks!

Chris



--
Sent from: http://numpy-discussion.10968.n7.nabble.com/
___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy FFT normalization options issue (addition of new option)

2020-06-05 Thread cvav
Ross Barnowski wrote
> One potential issue that stood out to me was the name of the new keyword
> option. At face value, "inverse" seems like a poor choice given the
> established use of the term in Fourier analysis. For example, one might
> expect `norm="inverse"` to mean that scaling is applied to the ifft, when
> this is actually the current default.

Yes that's true, the keyword argument name "inverse" is certainly something
I don't feel sure about. It'd be nice if everyone interested could suggest
names that make sense to them and what's their rationale behind them, so
that we pick something that's as self explanatory as possible. 

My thinking was to indicate that it's the opposite scaling to the default
option "None", so maybe something like "opposite" or "reversed" could be
other choices. Otherwise, we can find something that directly describes the
scaling and not its relationship to the default option.   

Chris



--
Sent from: http://numpy-discussion.10968.n7.nabble.com/
___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion