pub trait ArrayReorder<T: ArrayElement>where
    Self: Sized + Clone,{
    // 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§

source

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])));
source

fn flipud(&self) -> Result<Array<T>, ArrayError>

Reverse the order of elements along axis 0 (up/down)

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.flipud());
source

fn fliplr(&self) -> Result<Array<T>, ArrayError>

Reverse the order of elements along axis 1 (left/right)

Examples
use arr_rs::prelude::*;

let arr = array_arange!(i32, 0, 7).reshape(&[2, 2, 2]);
assert_eq!(array!(i32, [[[2, 3], [0, 1]], [[6, 7], [4, 5]]]), arr.fliplr());
source

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])));
source

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]));

Implementations on Foreign Types§

source§

impl<T: ArrayElement> ArrayReorder<T> for Result<Array<T>, ArrayError>

source§

fn flip(&self, axes: Option<Vec<isize>>) -> Result<Array<T>, ArrayError>

source§

fn flipud(&self) -> Result<Array<T>, ArrayError>

source§

fn fliplr(&self) -> Result<Array<T>, ArrayError>

source§

fn roll( &self, shift: Vec<isize>, axes: Option<Vec<isize>> ) -> Result<Array<T>, ArrayError>

source§

fn rot90(&self, k: usize, axes: Vec<isize>) -> Result<Array<T>, ArrayError>

Implementors§