Rotate 1D Array
- Updated2023-02-17
- 3 minute(s) read
Rotate 1D Array
Rotates the elements of an array a specified number of places and direction.

Inputs/Outputs

array
A 1D array of any type.
Data Type Changes on FPGA
When you add this node to a document targeted to an FPGA, this input has a default data type that uses fewer hardware resources at compile time.

n
The number of places and the direction to rotate array.
If n is positive, the indices of elements move right, and if n is negative, the indices of elements move left. For example, if n is 1, all elements in array move right one index place, so the first element becomes the second element and the last element becomes the first. If n is -1, all elements move left one index place, so the second element becomes the first element and the first element becomes the last. The node coerces n to a 32-bit integer if you wire another representation to it.

rotated array
array rotated according to n.
For example, if n is 1, the input array[0] becomes rotated array[1], input array[1] becomes rotated array[2], and so on, and input array[m-1] becomes rotated array[0], where m is the number of elements in the array. If n is -2, input array[0] becomes rotated array[m-2], input array[1] becomes rotated array[m-1], and so on, and input array[m-1] becomes rotated array[m-3], where m is the number of elements in the array.
Data Type Changes on FPGA
When you add this node to a document targeted to an FPGA, this output has a default data type that uses fewer hardware resources at compile time.
Examples
Diagram | Panel Indicator | Comments |
---|---|---|
![]() |
![]() |
When n is 1, all elements in the array input move right one index place, so the first element becomes the second element and the last element becomes the first. |
![]() |
![]() |
When n is -1. all elements in the array input move left one index place, so the second element becomes the first element and the first element becomes the last. |