flip
- arrayfire.flip(array: Array, /, *, axis: int = 0) Array
Flip an ArrayFire array along a specified dimension.
This function reverses the order of the elements of the input array along the specified axis (dimension). Flipping an array along its vertical axis (0) will invert the rows, whereas flipping along the horizontal axis (1) will invert the columns, and so on for higher dimensions.
Parameters
- arrayArray
The input multi-dimensional ArrayFire array to be flipped.
- axisint, optional, keyword-only, default: 0
The dimension along which to flip the array. For a 2D array, 0 flips it vertically, and 1 flips it horizontally.
Returns
- Array
The ArrayFire array resulting from flipping the input array along the specified axis.
Examples
>>> import arrayfire as af >>> a = af.randu((3, 3)) # Generate a random 3x3 array >>> a [3 3 1 1] 0.7269 0.3569 0.3341 0.7104 0.1437 0.0899 0.5201 0.4563 0.5363
>>> af.flip(a, axis=0) # Flip vertically [3 3 1 1] 0.5201 0.4563 0.5363 0.7104 0.1437 0.0899 0.7269 0.3569 0.3341
>>> af.flip(a, axis=1) # Flip horizontally [3 3 1 1] 0.3341 0.3569 0.7269 0.0899 0.1437 0.7104 0.5363 0.4563 0.5201