Function swap_rows

Source
pub fn swap_rows<E: ComplexField>(mat: MatMut<'_, E>, a: usize, b: usize)
Expand description

Swaps the two rows at indices a and b in the given matrix.

§Panics

Panics if either a or b is out of bounds.

§Example

use faer_core::{mat, permutation::swap_rows};

let mut m = mat![
    [1.0, 2.0, 3.0],
    [4.0, 5.0, 6.0],
    [7.0, 8.0, 9.0],
    [10.0, 14.0, 12.0],
];

swap_rows(m.as_mut(), 0, 2);

let swapped = mat![
    [7.0, 8.0, 9.0],
    [4.0, 5.0, 6.0],
    [1.0, 2.0, 3.0],
    [10.0, 14.0, 12.0],
];

assert_eq!(m, swapped);