1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::{DenseVector, DenseVectorMut};
///! Sparse linear algebra
///!
///! This module contains solvers for sparse linear systems. Currently
///! there are solver for sparse triangular systems and symmetric systems.
use num_traits::Num;

pub mod etree;
pub mod ordering;
pub mod trisolve;

pub use self::ordering::reverse_cuthill_mckee;

/// Diagonal solve
pub fn diag_solve<'a, N, V1, V2>(diag: V1, mut x: V2)
where
    N: 'a + Clone + Num + std::ops::DivAssign,
    for<'r> N: std::ops::DivAssign<&'r N>,
    V1: DenseVector<Scalar = N>,
    V2: DenseVectorMut + DenseVector<Scalar = N>,
{
    let n = x.dim();
    assert_eq!(diag.dim(), n);
    for i in 0..n {
        *x.index_mut(i) /= diag.index(i);
    }
}