roll_2d

Function roll_2d 

Source
pub fn roll_2d<T>(
    array: ArrayView<'_, T, Ix2>,
    shift_axis_0: isize,
    shift_axis_1: isize,
) -> Array<T, Ix2>
where T: Clone + Zero,
Expand description

Roll array elements along one or both axes

§Arguments

  • array - The input 2D array
  • shift_axis_0 - Number of places to shift along axis 0 (can be negative)
  • shift_axis_1 - Number of places to shift along axis 1 (can be negative)

§Returns

A new array with elements rolled as specified

§Examples

use ndarray::array;
use scirs2_core::ndarray_ext::manipulation::roll_2d;

let a = array![[1, 2, 3], [4, 5, 6]];

// Roll along rows by 1
let rolled_rows = roll_2d(a.view(), 1, 0);
assert_eq!(rolled_rows, array![[4, 5, 6], [1, 2, 3]]);

// Roll along columns by -1
let rolled_cols = roll_2d(a.view(), 0, -1);
assert_eq!(rolled_cols, array![[2, 3, 1], [5, 6, 4]]);