pub trait MatrixMut<T>: MatrixRef<T> {
// Required methods
fn get_mut(&mut self, row: usize, col: usize) -> &mut T;
fn col_as_mut_slice(&mut self, col: usize, row_start: usize) -> &mut [T];
}Expand description
Mutable access to a matrix-like type.
Extends MatrixRef with mutable element access, enabling
in-place algorithms (Cholesky, LU, etc.) to work generically.
§Example
use numeris::{Matrix, MatrixMut};
fn set_diag<T: numeris::Scalar>(m: &mut impl MatrixMut<T>, val: T) {
let n = m.nrows().min(m.ncols());
for i in 0..n {
*m.get_mut(i, i) = val;
}
}
let mut m: Matrix<f64, 2, 2> = Matrix::zeros();
set_diag(&mut m, 7.0);
assert_eq!(m[(0, 0)], 7.0);Required Methods§
Sourcefn get_mut(&mut self, row: usize, col: usize) -> &mut T
fn get_mut(&mut self, row: usize, col: usize) -> &mut T
Mutable reference to the element at (row, col).
Sourcefn col_as_mut_slice(&mut self, col: usize, row_start: usize) -> &mut [T]
fn col_as_mut_slice(&mut self, col: usize, row_start: usize) -> &mut [T]
Mutable contiguous slice of column col from row row_start to end.