deg2rad#
- ivy.deg2rad(x, /, *, out=None)[source]#
Convert the input from degrees to radians.
- Parameters:
- Return type:
- Returns:
ret – an array with each element in
x
converted from degrees to radians.
Examples
With
ivy.Array
input:>>> x=ivy.array([0,90,180,270,360]) >>> y=ivy.deg2rad(x) >>> print(y) ivy.array([0. , 1.57, 3.14, 4.71, 6.28])
>>> x=ivy.array([0,-1.5,-50,ivy.nan]) >>> y=ivy.zeros(5) >>> ivy.deg2rad(x,out=y) >>> print(y) ivy.array([ 0. , -0.0262, -0.873 , nan])
>>> x = ivy.array([[1.1, 2.2, 3.3],[-4.4, -5.5, -6.6]]) >>> ivy.deg2rad(x, out=x) >>> print(x) ivy.array([[ 0.0192, 0.0384, 0.0576], [-0.0768, -0.096 , -0.115 ]])
>>> x=ivy.native_array([-0,20.1,ivy.nan]) >>> y=ivy.zeros(3) >>> ivy.deg2rad(x,out=y) >>> print(y) ivy.array([0. , 0.351, nan])
With
ivy.Container
input:>>> x=ivy.Container(a=ivy.array([-0,20.1,-50.5,-ivy.nan]), b=ivy.array([0,90,180,270,360])) >>> y=ivy.deg2rad(x) >>> print(y) { a: ivy.array([0., 0.351, -0.881, nan]), b: ivy.array([0., 1.57, 3.14, 4.71, 6.28]) }
>>> x=ivy.Container(a=ivy.array([0,90,180,270,360]), ... b=ivy.native_array([0,-1.5,-50,ivy.nan])) >>> y=ivy.deg2rad(x) >>> print(y) { a: ivy.array([0., 1.57, 3.14, 4.71, 6.28]), b: ivy.array([0., -0.0262, -0.873, nan]) }
- Array.deg2rad(self, *, out=None)#
ivy.Array instance method variant of ivy.deg2rad. This method simply wraps the function, and so the docstring for ivy.deg2rad also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array. to be converted from degrees to radians.out (
Optional
[Array
]) – optional output, for writing the result to. It must have a shape that the (default:None
) inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the element-wise conversion from degrees to radians.
Examples
With
ivy.Array
input:>>> x=ivy.array([90,180,270,360]) >>> y=x.deg2rad() >>> print(y) ivy.array([1.57, 3.14, 4.71, 6.28])
- Container.deg2rad(self, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#
ivy.Container instance method variant of ivy.deg2rad. This method simply wraps the function, and so the docstring for ivy.deg2rad also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container. to be converted from degrees to radians.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
]]]) – The key-chains to apply or not apply the method to. Default isNone
. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default isTrue
.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default isFalse
.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). (default:False
) Default isFalse
.out (
Optional
[Container
]) – optional output container, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
- Return type:
Container
- Returns:
ret – a container with each element in
x
converted from degrees to radians.
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,ivy.nan])) >>> y=x.deg2rad() >>> print(y) { a: ivy.array([0., 0.00613, -0.0154, nan]), b: ivy.array([0., -0.0262, -0.873, nan]) }