Discussion:
[Numpy-discussion] ENH: `scale` parameter for `sinc`
Joseph Fox-Rabinovitz
2016-02-23 23:20:00 UTC
Permalink
I have created PR #7322 (https://github.com/numpy/numpy/pull/7322) to
add a scale parameter to `sinc`. What this allows is to compute `sinc`
as `sin(x)/x` or really `sin(n*x)/(n*x)` for arbitrary `n` instead of
just `sin(pi*x)/(pi*x)` as is being done now. The parameter accepts
two string arguments in addition to the actual scale value:
'normalized' and 'unnormalized'. 'normalized' is the default since
that is the existing functionality. 'unnormalized' is equivalent to a
`scale` of 1.0. The parameter also supports broadcasting against the
input array.

Regards,

-Joe

P.S. I would like to turn `sinc` into a `ufunc` at some point if the
community approves. It would make the computation much cleaner (e.g.,
in-place `where`) and faster. It would also complement the existing
trig functions nicely. The only question I have is whether or not it
is possible to pass in optional parameters to ufuncs beyond the ones
listed in http://docs.scipy.org/doc/numpy-1.10.0/reference/ufuncs.html#optional-keyword-arguments
Nathaniel Smith
2016-02-23 23:23:41 UTC
Permalink
On Tue, Feb 23, 2016 at 3:20 PM, Joseph Fox-Rabinovitz
Post by Joseph Fox-Rabinovitz
P.S. I would like to turn `sinc` into a `ufunc` at some point if the
community approves. It would make the computation much cleaner (e.g.,
in-place `where`) and faster. It would also complement the existing
trig functions nicely. The only question I have is whether or not it
is possible to pass in optional parameters to ufuncs beyond the ones
listed in http://docs.scipy.org/doc/numpy-1.10.0/reference/ufuncs.html#optional-keyword-arguments
Right now it isn't possible, no. There are a lot of general
improvements we can/should make to ufuncs, and this is one of them...

-n
--
Nathaniel J. Smith -- https://vorpus.org
Loading...