pub fn rollaxis<T: Clone + Zero>(
array: &Array<T>,
axis: usize,
start: usize,
) -> Result<Array<T>>Expand description
Roll the specified axis to a new position
§Parameters
array- The input arrayaxis- The axis to rollstart- The new position (destination)
§Returns
A new array with the axes rearranged
§Examples
use numrs2::prelude::*;
// Create a 3D array
let a = Array::from_vec(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
.reshape(&[2, 2, 3]);
// Roll axis 2 to position 0
let b = rollaxis(&a, 2, 0).expect("rollaxis should succeed for valid axes");
assert_eq!(b.shape(), vec![3, 2, 2]);