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
//! Define traits wrapping LAPACK routines

pub mod opnorm;
pub mod qr;
pub mod svd;
pub mod solve;
pub mod cholesky;
pub mod eigh;
pub mod triangular;

pub use self::cholesky::*;
pub use self::eigh::*;
pub use self::opnorm::*;
pub use self::qr::*;
pub use self::solve::*;
pub use self::svd::*;
pub use self::triangular::*;

use super::error::*;

trait_alias!(
    LapackScalar: OperatorNorm_,
    QR_,
    SVD_,
    Solve_,
    Cholesky_,
    Eigh_,
    Triangular_
);

pub fn into_result<T>(info: i32, val: T) -> Result<T> {
    if info == 0 {
        Ok(val)
    } else {
        Err(LapackError::new(info).into())
    }
}

/// Upper/Lower specification for seveal usages
#[derive(Debug, Clone, Copy)]
#[repr(u8)]
pub enum UPLO {
    Upper = b'U',
    Lower = b'L',
}

#[derive(Debug, Clone, Copy)]
#[repr(u8)]
pub enum Transpose {
    No = b'N',
    Transpose = b'T',
    Hermite = b'C',
}