collenchyma_blas/
transpose.rs

1//! Provides the Transpose functionality for Matrix operations.
2#[cfg(feature = "cuda")]
3use std::convert::From;
4#[cfg(feature = "cuda")]
5use cublas::api::Operation;
6
7#[derive(Debug, Copy, Clone)]
8/// Possible transpose operations that can be applied in Level 2 and Level 3 BLAS operations.
9pub enum Transpose {
10    /// Take the matrix as it is.
11    NoTrans,
12    /// Take the transpose of the matrix.
13    Trans,
14    /// Take the conjugate transpose of the matrix.
15    ConjTrans,
16}
17
18impl Transpose {
19    /// Create a rust-blas `Transpose` from collenchyma-blas `Transpose`.
20    pub fn to_rblas(&self) -> ::rblas::attribute::Transpose {
21        match *self {
22            Transpose::NoTrans => ::rblas::attribute::Transpose::NoTrans,
23            Transpose::Trans => ::rblas::attribute::Transpose::Trans,
24            Transpose::ConjTrans => ::rblas::attribute::Transpose::ConjTrans,
25        }
26    }
27}
28
29#[cfg(feature = "cuda")]
30impl From<Operation> for Transpose {
31    fn from(op: Operation) -> Self {
32        match op {
33            Operation::NoTrans => Transpose::NoTrans,
34            Operation::Trans => Transpose::Trans,
35            Operation::ConjTrans => Transpose::ConjTrans,
36        }
37    }
38}
39
40#[cfg(feature = "cuda")]
41impl From<Transpose> for Operation {
42    fn from(op: Transpose) -> Self {
43        match op {
44            Transpose::NoTrans => Operation::NoTrans,
45            Transpose::Trans => Operation::Trans,
46            Transpose::ConjTrans => Operation::ConjTrans,
47        }
48    }
49}