rot90#
- ivy.rot90(m, /, *, copy=None, k=1, axes=(0, 1), out=None)[source]#
Rotate an array by 90 degrees in the plane specified by axes. Rotation direction is from the first towards the second axis.
- Parameters:
m (
Union
[Array
,NativeArray
]) – Input array of two or more dimensions.k (
int
) – Number of times the array is rotated by 90 degrees. (default:1
)axes (
Tuple
[int
,int
]) – The array is rotated in the plane defined by the axes. Axes must be (default:(0, 1)
) different.out (
Optional
[Array
]) – optional output container, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
- Return type:
- Returns:
ret – A rotated view of m.
Examples
With
ivy.Array
input: >>> m = ivy.array([[1,2], [3,4]]) >>> ivy.rot90(m) ivy.array([[2, 4],[1, 3]])
>>> m = ivy.array([[1,2], [3,4]]) >>> ivy.rot90(m, k=2) ivy.array([[4, 3], [2, 1]]) >>> m = ivy.array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]) >>> ivy.rot90(m, k=2, axes=(1,2)) ivy.array([[[3, 2], [1, 0]],
- [[7, 6],
[5, 4]]])
With
ivy.NativeArray
input: >>> m = ivy.native_array([[1,2], [3,4]]) >>> ivy.rot90(m) ivy.array([[2, 4],[1, 3]])
>>> m = ivy.native_array([[1,2], [3,4]]) >>> ivy.rot90(m, k=2) ivy.array([[4, 3], [2, 1]]) >>> m = ivy.native_array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]) >>> ivy.rot90(m, k=2, axes=(1,2)) ivy.array([[[3, 2], [1, 0]],
- [[7, 6],
[5, 4]]])
- Array.rot90(self, /, *, copy=None, k=1, axes=(0, 1), out=None)#
ivy.Array instance method variant of ivy.rot90. This method simply wraps the function, and so the docstring for ivy.rot90 also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array of two or more dimensions.k (
int
) – Number of times the array is rotated by 90 degrees. (default:1
)axes (
Tuple
[int
,int
]) – The array is rotated in the plane defined by the axes. Axes must be (default:(0, 1)
) different.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 – Array with a rotated view of input array.
Examples
>>> m = ivy.array([[1,2], [3,4]]) >>> m.rot90() ivy.array([[2, 4], [1, 3]]) >>> m = ivy.array([[1,2], [3,4]]) >>> m.rot90(k=2) ivy.array([[4, 3], [2, 1]]) >>> m = ivy.array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]) >>> m.rot90(k=2, axes=(1,2)) ivy.array([[[3, 2], [1, 0]],
- [[7, 6],
[5, 4]]])
- Container.rot90(self, /, *, copy=None, k=1, axes=(0, 1), key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#
ivy.Container static method variant of ivy.rot90. This method simply wraps the function, and so the docstring for ivy.rot90 also applies to this method with minimal changes.
- Parameters:
self (
Union
[Container
,Array
,NativeArray
]) – Input array of two or more dimensions.k (
int
) – Number of times the array is rotated by 90 degrees. (default:1
)axes (
Tuple
[int
,int
]) – The array is rotated in the plane defined by the axes. Axes must be (default:(0, 1)
) different.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
]]]) – The key-chains to apply or not apply the method to. Default is None. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default is True.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default is False.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). Default is False. (default:False
)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 – Container with a rotated view of input array.
Examples
>>> m = ivy.Container(a=ivy.array([[1,2], [3,4]]), ... b=ivy.array([[1,2,3,4],[7,8,9,10]])) >>> n = m.rot90() >>> print(n) { a: ivy.array([[2, 4], [1, 3]]), b: ivy.array([[4, 10], [3, 9], [2, 8], [1, 7]]) }