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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! Error enum
pub use svd::types::SVDError;
pub use eigenvalues::types::{EigenError};
pub use solve_linear::types::SolveError;
pub use least_squares::LeastSquaresError;
pub use generate::GenerateError;
pub use factorization::qr::QRError;
pub use factorization::lu::LUError;
pub use factorization::cholesky::CholeskyError;

/// Universal `linxal` error enum
///
/// This enum can be used as a catch-all for errors from `linxal`
/// computations.
#[derive(Debug)]
pub enum Error {
    /// Error from an SVD opeartion
    SVD(SVDError),

    /// Error from an eigenvalue operation (general or symmetric)
    Eigen(EigenError),

    /// Error from attempting a least-squares solution
    LeastSquares(LeastSquaresError),

    /// Error from solving a linear equation
    SolveLinear(SolveError),

    /// Error from computing a QR-decomposition
    QR(QRError),

    /// Error from computing an LU-decomposition
    LU(LUError),

    /// Error from computing a Cholesky decomposition
    Cholesky(CholeskyError),

    /// Error from attempting to generate a matrix
    Generate(GenerateError),
}

impl From<SVDError> for Error {
    fn from(e: SVDError) -> Error {
        Error::SVD(e)
    }
}

impl From<EigenError> for Error {
    fn from(e: EigenError) -> Error {
        Error::Eigen(e)
    }
}

impl From<LeastSquaresError> for Error {
    fn from(e: LeastSquaresError) -> Error {
        Error::LeastSquares(e)
    }
}

impl From<SolveError> for Error {
    fn from(e: SolveError) -> Error {
        Error::SolveLinear(e)
    }
}

impl From<QRError> for Error {
    fn from(e: QRError) -> Error {
        Error::QR(e)
    }
}

impl From<LUError> for Error {
    fn from(e: LUError) -> Error {
        Error::LU(e)
    }
}

impl From<CholeskyError> for Error {
    fn from(e: CholeskyError) -> Error {
        Error::Cholesky(e)
    }
}

impl From<GenerateError> for Error {
    fn from(e: GenerateError) -> Error {
        Error::Generate(e)
    }
}