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
//! Provides the Transpose functionality for Matrix operations.
#[cfg(feature = "cuda")]
use std::convert::From;
#[cfg(feature = "cuda")]
use cublas::api::Operation;

#[derive(Debug, Copy, Clone)]
/// Possible transpose operations that can be applied in Level 2 and Level 3 BLAS operations.
pub enum Transpose {
    /// Take the matrix as it is.
    NoTrans,
    /// Take the transpose of the matrix.
    Trans,
    /// Take the conjugate transpose of the matrix.
    ConjTrans,
}

impl Transpose {
    /// Create a rust-blas `Transpose` from coaster-blas `Transpose`.
    pub fn to_rblas(&self) -> ::rblas::attribute::Transpose {
        match *self {
            Transpose::NoTrans => ::rblas::attribute::Transpose::NoTrans,
            Transpose::Trans => ::rblas::attribute::Transpose::Trans,
            Transpose::ConjTrans => ::rblas::attribute::Transpose::ConjTrans,
        }
    }
}

#[cfg(feature = "cuda")]
impl From<Operation> for Transpose {
    fn from(op: Operation) -> Self {
        match op {
            Operation::NoTrans => Transpose::NoTrans,
            Operation::Trans => Transpose::Trans,
            Operation::ConjTrans => Transpose::ConjTrans,
        }
    }
}

#[cfg(feature = "cuda")]
impl From<Transpose> for Operation {
    fn from(op: Transpose) -> Self {
        match op {
            Transpose::NoTrans => Operation::NoTrans,
            Transpose::Trans => Operation::Trans,
            Transpose::ConjTrans => Operation::ConjTrans,
        }
    }
}