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
xconverted from degrees to radians.
Examples
With
ivy.Arrayinput:>>> x=ivy.array([0,90,180,270,360], dtype=ivy.float32) >>> y=ivy.deg2rad(x) >>> print(y) ivy.array([0., 1.57079633, 3.14159265, 4.71238898, 6.28318531])
>>> x=ivy.array([0,-1.5,-50,ivy.nan]) >>> y=ivy.zeros(4) >>> ivy.deg2rad(x,out=y) >>> print(y) ivy.array([ 0., -0.02617994, -0.87266463, 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.01919862, 0.03839725, 0.05759586], [-0.07679449, -0.09599311, -0.11519173]])
>>> x=ivy.native_array([-0,20.1,ivy.nan]) >>> y=ivy.zeros(3) >>> ivy.deg2rad(x,out=y) >>> print(y) ivy.array([0., 0.35081118, nan])
With
ivy.Containerinput:>>> x=ivy.Container(a=ivy.array([-0,20.1,-50.5,-ivy.nan]), ... b=ivy.array([0,90.,180,270,360], dtype=ivy.float32)) >>> y=ivy.deg2rad(x) >>> print(y) { a: ivy.array([0., 0.35081118, -0.88139129, nan]), b: ivy.array([0., 1.57079633, 3.14159265, 4.71238898, 6.28318531]) }
>>> x=ivy.Container(a=ivy.array([0,90,180,270,360], dtype=ivy.float32), ... b=ivy.native_array([0,-1.5,-50,ivy.nan])) >>> y=ivy.deg2rad(x) >>> print(y) { a: ivy.array([0., 1.57079633, 3.14159265, 4.71238898, 6.28318531]), b: ivy.array([0., -0.02617994, -0.87266463, nan]) }
- Array.deg2rad(self, *, out=None)[source]#
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], 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 degrees to radians.
Examples
With
ivy.Arrayinput:>>> 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)[source]#
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],Container]], default:None) – The key-chains to apply or not apply the method to. Default isNone.to_apply (
Union[bool,Container], default:True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue.prune_unapplied (
Union[bool,Container], default:False) – Whether to prune key_chains for which the function was not applied. Default isFalse.map_sequences (
Union[bool,Container], default:False) – Whether to also map method to sequences (lists, tuples). Default isFalse.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
xconverted from degrees to radians.
Examples
With
ivy.Containerinput:>>> 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]) }