Skip to content

Commit 4f848a2

Browse files
committed
Add dpnp.sinc function to the interface
1 parent 1a41808 commit 4f848a2

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

dpnp/dpnp_iface_mathematical.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
"round",
131131
"sign",
132132
"signbit",
133+
"sinc",
133134
"subtract",
134135
"sum",
135136
"trapezoid",
@@ -3749,6 +3750,75 @@ def real_if_close(a, tol=100):
37493750
)
37503751

37513752

3753+
_SINC_DOCSTRING = r"""
3754+
Return the normalized sinc function.
3755+
3756+
The sinc function is equal to :math:`\sin(\pi x)/(\pi x)` for any argument
3757+
:math:`x\ne 0`. ``sinc(0)`` takes the limit value 1, making ``sinc`` not
3758+
only everywhere continuous but also infinitely differentiable.
3759+
3760+
For full documentation refer to :obj:`numpy.sinc`.
3761+
3762+
Parameters
3763+
----------
3764+
x : {dpnp.ndarray, usm_ndarray}
3765+
Input array, expected to have floating-point type.
3766+
out : {None, dpnp.ndarray, usm_ndarray}, optional
3767+
Output array to populate.
3768+
Array must have the correct shape and the expected data type.
3769+
Default: ``None``.
3770+
order : {"C", "F", "A", "K"}, optional
3771+
Memory layout of the newly output array, if parameter `out` is ``None``.
3772+
Default: ``"K"``.
3773+
3774+
Returns
3775+
-------
3776+
out : dpnp.ndarray
3777+
An array containing the element-wise result of the ``sinc(x)`` function.
3778+
The data type of the returned array is determined by the Type Promotion
3779+
Rules.
3780+
3781+
Limitations
3782+
-----------
3783+
Parameters `where` and `subok` are supported with their default values.
3784+
Keyword argument `kwargs` is currently unsupported.
3785+
Otherwise ``NotImplementedError`` exception will be raised.
3786+
3787+
Notes
3788+
-----
3789+
The name sinc is short for "sine cardinal" or "sinus cardinalis".
3790+
3791+
The sinc function is used in various signal processing applications, including
3792+
in anti-aliasing, in the construction of a Lanczos resampling filter, and in
3793+
interpolation.
3794+
3795+
For bandlimited interpolation of discrete-time signals, the ideal interpolation
3796+
kernel is proportional to the sinc function.
3797+
3798+
Examples
3799+
--------
3800+
>>> import dpnp as np
3801+
>>> x = np.linspace(-4, 4, 41, dtype=dpnp.float64)
3802+
>>> np.sinc(x) # result may vary
3803+
array([ 0. , -0.04923628, -0.08409186, -0.08903844, -0.05846808,
3804+
0. , 0.06682066, 0.11643488, 0.12613779, 0.08504448,
3805+
0. , -0.10394325, -0.18920668, -0.21623621, -0.15591488,
3806+
0. , 0.23387232, 0.50455115, 0.75682673, 0.93548928,
3807+
1. , 0.93548928, 0.75682673, 0.50455115, 0.23387232,
3808+
0. , -0.15591488, -0.21623621, -0.18920668, -0.10394325,
3809+
0. , 0.08504448, 0.12613779, 0.11643488, 0.06682066,
3810+
0. , -0.05846808, -0.08903844, -0.08409186, -0.04923628,
3811+
0. ])
3812+
"""
3813+
3814+
sinc = DPNPUnaryFunc(
3815+
"sinc",
3816+
ufi._sinc_result_type,
3817+
ufi._sinc,
3818+
_SINC_DOCSTRING,
3819+
)
3820+
3821+
37523822
_SUBTRACT_DOCSTRING = """
37533823
Calculates the difference between each element `x1_i` of the input
37543824
array `x1` and the respective element `x2_i` of the input array `x2`.

0 commit comments

Comments
 (0)