rust_blas/math/
mod.rs

1// Copyright 2015 Michael Yang. All rights reserved.
2// Use of this source code is governed by a MIT-style
3// license that can be found in the LICENSE file.
4
5use crate::matrix::Matrix;
6use crate::vector::Vector;
7use std::ops::{BitXor, Deref};
8
9pub use self::mat::Mat;
10
11pub mod bandmat;
12pub mod mat;
13pub mod matrix;
14pub mod matrix_vector;
15pub mod vector;
16
17pub enum Trans<A> {
18    T(A),
19    H(A),
20}
21
22impl<A> Deref for Trans<A> {
23    type Target = A;
24
25    fn deref(&self) -> &A {
26        match *self {
27            Trans::T(ref v) => v,
28            Trans::H(ref v) => v,
29        }
30    }
31}
32
33pub enum Marker {
34    T,
35    H,
36}
37
38impl<'a, T> BitXor<Marker> for &'a dyn Vector<T> {
39    type Output = Trans<&'a dyn Vector<T>>;
40
41    fn bitxor(self, m: Marker) -> Trans<&'a dyn Vector<T>> {
42        match m {
43            Marker::T => Trans::T(self),
44            Marker::H => Trans::H(self),
45        }
46    }
47}
48
49impl<'a, T> BitXor<Marker> for &'a dyn Matrix<T> {
50    type Output = Trans<&'a dyn Matrix<T>>;
51
52    fn bitxor(self, m: Marker) -> Trans<&'a dyn Matrix<T>> {
53        match m {
54            Marker::T => Trans::T(self),
55            Marker::H => Trans::H(self),
56        }
57    }
58}