rad2deg#

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

Convert the input from radians to degrees.

Parameters:
  • x (Union[Array, NativeArray]) – input array whose elements are each expressed in radians.

  • 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 with each element in x converted from radians to degrees.

Examples

With ivy.Array input:

>>> x=ivy.array([0.,1.57,3.14,4.71,6.28])
>>> y=ivy.rad2deg(x)
>>> print(y)
ivy.array([  0.,  90., 180., 270., 360.])
>>> x=ivy.array([0.,-0.0262,-0.873,ivy.nan])
>>> y=ivy.zeros(4)
>>> ivy.rad2deg(x,out=y)
>>> print(y)
ivy.array([  0. ,  -1.5, -50. ,   nan])
>>> x = ivy.array([[1.1, 2.2, 3.3],[-4.4, -5.5, -6.6]])
>>> ivy.rad2deg(x, out=x)
>>> print(x)
ivy.array([[  63.,  126.,  189.],
    [-252., -315., -378.]])
>>> x=ivy.native_array([-0,20.1,ivy.nan])
>>> y=ivy.zeros(3)
>>> ivy.rad2deg(x,out=y)
>>> print(y)
ivy.array([   0., 1150.,   nan])

With ivy.Container input:

>>> x=ivy.Container(a=ivy.array([-0., 20.1, -50.5, -ivy.nan]),
...                 b=ivy.array([0., 1., 2., 3., 4.]))
>>> y=ivy.rad2deg(x)
>>> print(y)
{
    a: ivy.array([0., 1150., -2890., nan]),
    b: ivy.array([0., 57.3, 115., 172., 229.])
}
>>> x=ivy.Container(a=ivy.array([0,10,180,8.5,6]),
...                 b=ivy.native_array([0,-1.5,0.5,ivy.nan]))
>>> y=ivy.rad2deg(x)
>>> print(y)
{
    a: ivy.array([0., 573., 10300., 487., 344.]),
    b: ivy.array([0., -85.9, 28.6, nan])
}
Array.rad2deg(self, *, out=None)[source]#

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

Parameters:
  • self (Array) – input array. to be converted from degrees to radians.

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

Return type:

Array

Returns:

ret – an array containing the element-wise conversion from radians to degrees.

Examples

With ivy.Array input:

>>> x=ivy.array([1., 5., 8., 10.])
>>> y=x.rad2deg()
>>> print(y)
ivy.array([ 57.3, 286. , 458. , 573. ])
Container.rad2deg(self, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container. to be converted from radians to degrees.

  • 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 with each element in x converted from radians to degrees.

Examples

With ivy.Container input:

>>> x=ivy.Container(a=ivy.array([0., 0.351, -0.881, ivy.nan]),
...                 b=ivy.native_array([0,-1.5,-50,7.2]))
>>> y=x.rad2deg()
>>> print(y)
{
    a: ivy.array([0., 20.1, -50.5, nan]),
    b: ivy.array([0., -85.9, -2860., 413.])
}