Skip to main content

conspire/math/sparse/
mod.rs

1mod factor;
2mod matrix;
3mod solver;
4
5pub use factor::{CscLdl, CscLu};
6pub use matrix::CscMatrix;
7pub use solver::SparseSolver;
8
9use crate::math::{Style, StyledError, assert::AssertionError, styled_error};
10
11/// Possible errors for sparse data types.
12#[derive(PartialEq)]
13pub enum SparseError {
14    Singular,
15    Unsymmetric,
16}
17
18impl StyledError for SparseError {
19    fn message(&self, style: &Style) -> String {
20        let h = style.headline;
21        match self {
22            Self::Singular => format!("{h}Matrix is singular."),
23            Self::Unsymmetric => format!("{h}Matrix is not symmetric."),
24        }
25    }
26}
27
28styled_error!(SparseError);
29
30impl From<SparseError> for AssertionError {
31    fn from(error: SparseError) -> Self {
32        Self {
33            message: error.to_string(),
34        }
35    }
36}