pub trait ArrayReorder<T: ArrayElement>{
// Required methods
fn flip(&self, axes: Option<Vec<isize>>) -> Result<Array<T>, ArrayError>;
fn flipud(&self) -> Result<Array<T>, ArrayError>;
fn fliplr(&self) -> Result<Array<T>, ArrayError>;
fn roll(
&self,
shift: Vec<isize>,
axes: Option<Vec<isize>>,
) -> Result<Array<T>, ArrayError>;
fn rot90(&self, k: usize, axes: Vec<isize>) -> Result<Array<T>, ArrayError>;
}
Expand description
ArrayTrait
- Array Reordering functions
Required Methods§
Sourcefn flip(&self, axes: Option<Vec<isize>>) -> Result<Array<T>, ArrayError>
fn flip(&self, axes: Option<Vec<isize>>) -> Result<Array<T>, ArrayError>
Reverse the order of elements in an array along the given axis
§Arguments
axes
- axes along which to flip over. if None, will flip over all of the axes.
§Examples
use arr_rs::prelude::*;
let arr = array_arange!(i32, 0, 7).reshape(&[2, 2, 2]);
assert_eq!(array!(i32, [[[1, 0], [3, 2]], [[5, 4], [7, 6]]]), arr.flip(Some(vec![2])));
§Errors
may returns ArrayError
Sourcefn flipud(&self) -> Result<Array<T>, ArrayError>
fn flipud(&self) -> Result<Array<T>, ArrayError>
Sourcefn fliplr(&self) -> Result<Array<T>, ArrayError>
fn fliplr(&self) -> Result<Array<T>, ArrayError>
Sourcefn roll(
&self,
shift: Vec<isize>,
axes: Option<Vec<isize>>,
) -> Result<Array<T>, ArrayError>
fn roll( &self, shift: Vec<isize>, axes: Option<Vec<isize>>, ) -> Result<Array<T>, ArrayError>
Roll array elements along a given axis
§Arguments
shift
- number of places by which elements are shifted. if a tuple, then axis must be a tuple of the same size, and each of the given axes is shifted by the corresponding number. if an int while axis is a tuple of ints, then the same value is used for all given axes.axes
- axes along which to roll over. if None, will flip over all of the axes.
§Examples
use arr_rs::prelude::*;
let arr = array_arange!(i32, 0, 7).reshape(&[2, 2, 2]);
assert_eq!(array!(i32, [[[4, 5], [6, 7]], [[0, 1], [2, 3]]]), arr.roll(vec![1], Some(vec![0])));
§Errors
may returns ArrayError
Sourcefn rot90(&self, k: usize, axes: Vec<isize>) -> Result<Array<T>, ArrayError>
fn rot90(&self, k: usize, axes: Vec<isize>) -> Result<Array<T>, ArrayError>
Rotate an array by 90 degrees in the plane specified by axes. Rotation direction is from the first towards the second axis.
§Arguments
k
- number of times the array is rotated by 90 degrees.axes
- the array is rotated in the plane defined by the axes. axes must be different.
§Examples
use arr_rs::prelude::*;
let arr = array_arange!(i32, 0, 7).reshape(&[2, 4]);
assert_eq!(array!(i32, [[3, 7], [2, 6], [1, 5], [0, 4]]), arr.rot90(1, vec![0, 1]));
§Errors
may returns ArrayError
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.