array_api_extra.sinc

array_api_extra.sinc(x, /, *, xp)

Return the normalized sinc function.

The sinc function is equal to \(\sin(\pi x)/(\pi x)\) for any argument \(x\ne 0\). sinc(0) takes the limit value 1, making sinc not only everywhere continuous but also infinitely differentiable.

Note

Note the normalization factor of pi used in the definition. This is the most commonly used definition in signal processing. Use sinc(x / xp.pi) to obtain the unnormalized sinc function \(\sin(x)/x\) that is more common in mathematics.

Parameters:
  • x (array) – Array (possibly multi-dimensional) of values for which to calculate sinc(x). Must have a real floating point dtype.

  • xp (array_namespace) – The standard-compatible namespace for x.

Returns:

ressinc(x) calculated elementwise, which has the same shape as the input.

Return type:

array

Notes

The name sinc is short for “sine cardinal” or “sinus cardinalis”.

The sinc function is used in various signal processing applications, including in anti-aliasing, in the construction of a Lanczos resampling filter, and in interpolation.

For bandlimited interpolation of discrete-time signals, the ideal interpolation kernel is proportional to the sinc function.

References

Examples

>>> import array_api_strict as xp
>>> import array_api_extra as xpx
>>> x = xp.linspace(-4, 4, 41)
>>> xpx.sinc(x, xp=xp)
Array([-3.89817183e-17, -4.92362781e-02,
       -8.40918587e-02, -8.90384387e-02,
       -5.84680802e-02,  3.89817183e-17,
        6.68206631e-02,  1.16434881e-01,
        1.26137788e-01,  8.50444803e-02,
       -3.89817183e-17, -1.03943254e-01,
       -1.89206682e-01, -2.16236208e-01,
       -1.55914881e-01,  3.89817183e-17,
        2.33872321e-01,  5.04551152e-01,
        7.56826729e-01,  9.35489284e-01,
        1.00000000e+00,  9.35489284e-01,
        7.56826729e-01,  5.04551152e-01,
        2.33872321e-01,  3.89817183e-17,
       -1.55914881e-01, -2.16236208e-01,
       -1.89206682e-01, -1.03943254e-01,
       -3.89817183e-17,  8.50444803e-02,
        1.26137788e-01,  1.16434881e-01,
        6.68206631e-02,  3.89817183e-17,
       -5.84680802e-02, -8.90384387e-02,
       -8.40918587e-02, -4.92362781e-02,
       -3.89817183e-17], dtype=array_api_strict.float64)