flopscope.numpy.rot90
fnp.rot90(m, k=1, axes=(0, 1))[flopscope source][numpy source]
Rotate an array by 90 degrees in the plane specified by axes.
Adapted from NumPy docs np.rot90
Cost
0
Flopscope Context
Rotate array 90 degrees.
Rotation direction is from the first towards the second axis.
This means for a 2D array with the default k and axes, the
rotation will be counterclockwise.
Parameters
- m:array_like
Array of two or more dimensions.
- k:integer
Number of times the array is rotated by 90 degrees.
- axes:(2,) array_like
The array is rotated in the plane defined by the axes. Axes must be different.
Returns
- y:ndarray
A rotated view of
m.
See also
- we.flops.flip Reverse the order of elements in an array along the given axis.
- we.flops.fliplr Flip an array horizontally.
- we.flops.flipud Flip an array vertically.
Notes
rot90(m, k=1, axes=(1,0)) is the reverse of
rot90(m, k=1, axes=(0,1))
rot90(m, k=1, axes=(1,0)) is equivalent to
rot90(m, k=-1, axes=(0,1))
Examples
>>> import flopscope.numpy as fnp
>>> m = flops.array([[1,2],[3,4]], int)
>>> m
array([[1, 2],
[3, 4]])
>>> flops.rot90(m)
array([[2, 4],
[1, 3]])
>>> flops.rot90(m, 2)
array([[4, 3],
[2, 1]])
>>> m = flops.arange(8).reshape((2,2,2))
>>> flops.rot90(m, 1, (1,2))
array([[[1, 3],
[0, 2]],
[[5, 7],
[4, 6]]])