Function extendr_api::prelude::perm::swap_cols
pub fn swap_cols<E>(a: ColMut<'_, E>, b: ColMut<'_, E>)where
E: ComplexField,
Expand description
Swaps the values in the columns a
and b
.
§Panics
Panics if a
and b
don’t have the same number of columns.
§Example
use faer::{mat, perm::swap_cols};
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],
];
let (a, b) = m.as_mut().two_cols_mut(0, 2);
swap_cols(a, b);
let swapped = mat![
[3.0, 2.0, 1.0],
[6.0, 5.0, 4.0],
[9.0, 8.0, 7.0],
[12.0, 14.0, 10.0],
];
assert_eq!(m, swapped);