1#[derive(Debug, thiserror::Error)]
5pub enum SolverError {
6 #[error("matrix must be square: got {rows}x{cols}")]
8 NotSquare {
9 rows: usize,
11 cols: usize,
13 },
14
15 #[error("singular matrix: zero pivot at position {0}")]
17 SingularMatrix(usize),
18
19 #[error("matrix is not positive definite: non-positive diagonal at position {0}")]
21 NotPositiveDefinite(usize),
22
23 #[error("dimension mismatch: matrix is {matrix_n}x{matrix_n}, rhs has {rhs_len} elements")]
25 DimensionMismatch {
26 matrix_n: usize,
28 rhs_len: usize,
30 },
31
32 #[error("SVD: matrix is {m}x{n}, but output buffers have wrong dimensions")]
34 SvdDimensionMismatch {
35 m: usize,
37 n: usize,
39 },
40
41 #[error("QR: matrix is {m}x{n} (requires m >= n)")]
43 QrNotTallSkinny {
44 m: usize,
46 n: usize,
48 },
49
50 #[error("invalid input: {reason}")]
52 InvalidInput {
53 reason: &'static str,
55 },
56
57 #[error("buffer length {got} does not match expected {expected} for {rows}x{cols} matrix")]
59 BufferLengthMismatch {
60 expected: usize,
62 got: usize,
64 rows: usize,
66 cols: usize,
68 },
69}