Skip to main content

swap_rows

Function swap_rows 

Source
pub fn swap_rows<T>(m: &mut Matrix<T>, a: usize, b: usize)
Expand description

Swap two rows in a matrix in-place.

No-op if a == b.

ยงExamples

use tensor4all_tcicore::{from_vec2d, matrix::swap_rows};

let mut m = from_vec2d(vec![vec![1.0, 2.0], vec![3.0, 4.0]]);
swap_rows(&mut m, 0, 1);
assert_eq!(m[[0, 0]], 3.0);
assert_eq!(m[[1, 0]], 1.0);