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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/// Errors returned by FERAL's public API.
#[derive(Debug)]
pub enum FeralError {
/// The matrix is numerically rank-deficient: a pivot was exactly or
/// near-zero and `ZeroPivotAction::Fail` was specified. The factorization
/// is incomplete.
NumericallyRankDeficient,
/// Input matrix dimensions are inconsistent or the matrix is not square.
InvalidInput(String),
/// The RHS vector length does not match the factored matrix dimension.
DimensionMismatch { expected: usize, got: usize },
/// An I/O or parse error occurred (e.g. reading a Matrix Market file).
IoError(String),
/// `Solver::solve` (or `solve_refined`) was called before any
/// successful factorization. Call `factor()` first.
NoFactor,
}
impl std::fmt::Display for FeralError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
FeralError::NumericallyRankDeficient => {
write!(f, "matrix is numerically rank-deficient")
}
FeralError::InvalidInput(msg) => write!(f, "invalid input: {}", msg),
FeralError::DimensionMismatch { expected, got } => {
write!(f, "dimension mismatch: expected {}, got {}", expected, got)
}
FeralError::IoError(msg) => write!(f, "I/O error: {}", msg),
FeralError::NoFactor => {
write!(f, "no factorization available; call Solver::factor() first")
}
}
}
}
impl std::error::Error for FeralError {}