sinc

paddle. sinc ( x, name=None ) [source]

Calculate the normalized sinc of x elementwise.

\[\begin{split}out_i = \left\{ \begin{aligned} &1 & \text{ if $x_i = 0$} \\ &\frac{\sin(\pi x_i)}{\pi x_i} & \text{ otherwise} \end{aligned} \right.\end{split}\]
Parameters
  • x (Tensor) – The input Tensor. Must be one of the following types: bfloat16, float16, float32, float64.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

out (Tensor), The Tensor of elementwise-computed normalized sinc result.

Examples

>>> import paddle
>>> paddle.set_device('cpu')
>>> paddle.seed(100)
>>> x = paddle.rand([2,3], dtype='float32')
>>> res = paddle.sinc(x)
>>> print(res)
Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
[[0.56691176, 0.93089867, 0.99977750],
 [0.61639023, 0.79618412, 0.89171958]])