sinc#

ivy.sinc(x, /, *, out=None)[source]#

Calculate an implementation-dependent approximation of the principal value of the normalized sinc function, having domain (-infinity, +infinity) and codomain [-0.217234, 1], for each element x_i of the input array x. Each element x_i is assumed to be expressed in radians.

Special cases

For floating-point operands,

  • If x_i is NaN, the result is NaN.

  • If x_i is 0, the result is 1.

  • If x_i is either +infinity or -infinity, the result is NaN.

Parameters:
  • x (Union[Array, NativeArray]) – input array. Should have a floating-point data type.

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

ret – an array containing the normalized sinc function of each element in x. The returned array must have a floating-point data type determined by type-promotion.

Examples

With ivy.Array input:

>>> x = ivy.array([0.5, 1.5, 2.5, 3.5])
>>> y = x.sinc()
>>> print(y)
ivy.array([0.637,-0.212,0.127,-0.0909])
>>> x = ivy.array([1.5, 0.5, -1.5])
>>> y = ivy.zeros(3)
>>> ivy.sinc(x, out=y)
>>> print(y)
ivy.array([-0.212,0.637,-0.212])

With ivy.NativeArray input:

>>> x = ivy.array([0.5, 1.5, 2.5, 3.5])
>>> y = ivy.sinc(x)
>>> print(y)
ivy.array([0.637,-0.212,0.127,-0.0909])

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([0.5, 1.5, 2.5]),
...                   b=ivy.array([3.5, 4.5, 5.5]))
>>> y = x.sinc()
>>> print(y)
{
    a: ivy.array([0.637,-0.212,0.127]),
    b: ivy.array([-0.0909,0.0707,-0.0579])
}
Array.sinc(self, *, out=None)[source]#

ivy.Array instance method variant of ivy.sinc. This method simply wraps the function, and so the docstring for ivy.sinc also applies to this method with minimal changes.

Parameters:
  • self (Array) – input array whose elements are each expressed in radians. Should have a floating-point data type.

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

ret – an array containing the sinc of each element in self. The returned array must have a floating-point data type determined by type-promotion.

Examples

>>> x = ivy.array([0.5, 1.5, 2.5, 3.5])
>>> y = x.sinc()
>>> print(y)
ivy.array([0.637,-0.212,0.127,-0.0909])
Container.sinc(self, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.sinc. This method simply wraps the function, and so the docstring for ivy.sinc also applies to this method with minimal changes.

Parameters:
  • self (Container) – input container whose elements are each expressed in radians. Should have a floating-point data type.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the sinc of each element in self. The returned container must have a floating-point data type determined by type-promotion.

Examples

>>> x = ivy.Container(a=ivy.array([0.5, 1.5, 2.5]),
...                   b=ivy.array([3.5, 4.5, 5.5]))
>>> y = x.sinc()
>>> print(y)
{
    a: ivy.array([0.637,-0.212,0.127]),
    b: ivy.array([-0.0909,0.0707,-0.0579])
}