Skip to main content

MatrixMut

Trait MatrixMut 

Source
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§

Source

fn get_mut(&mut self, row: usize, col: usize) -> &mut T

Mutable reference to the element at (row, col).

Source

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.

Implementations on Foreign Types§

Source§

impl<T: Scalar + Scalar> MatrixMut<T> for DMatrix<T>

Source§

fn get_mut(&mut self, row: usize, col: usize) -> &mut T

Source§

fn col_as_mut_slice(&mut self, col: usize, row_start: usize) -> &mut [T]

Source§

impl<T: Scalar + Scalar, const M: usize, const N: usize> MatrixMut<T> for SMatrix<T, M, N>
where Const<M>: DimName, Const<N>: DimName,

Source§

fn get_mut(&mut self, row: usize, col: usize) -> &mut T

Source§

fn col_as_mut_slice(&mut self, col: usize, row_start: usize) -> &mut [T]

Implementors§

Source§

impl<T> MatrixMut<T> for DynMatrix<T>

Source§

impl<T> MatrixMut<T> for DynVector<T>

Source§

impl<T, const M: usize, const N: usize> MatrixMut<T> for Matrix<T, M, N>