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
use crate::matrix::Matrix;
use crate::vector::Vector;
use std::ops::{BitXor, Deref};
pub use self::mat::Mat;
pub mod mat;
pub mod bandmat;
pub mod matrix;
pub mod matrix_vector;
pub mod vector;
pub enum Trans<A> {
T(A),
H(A),
}
impl<A> Deref for Trans<A> {
type Target = A;
fn deref(&self) -> &A {
match *self {
Trans::T(ref v) => v,
Trans::H(ref v) => v,
}
}
}
pub enum Marker {
T,
H,
}
impl<'a, T> BitXor<Marker> for &'a dyn Vector<T> {
type Output = Trans<&'a dyn Vector<T>>;
fn bitxor(self, m: Marker) -> Trans<&'a dyn Vector<T>> {
match m {
Marker::T => Trans::T(self),
Marker::H => Trans::H(self),
}
}
}
impl<'a, T> BitXor<Marker> for &'a dyn Matrix<T> {
type Output = Trans<&'a dyn Matrix<T>>;
fn bitxor(self, m: Marker) -> Trans<&'a dyn Matrix<T>> {
match m {
Marker::T => Trans::T(self),
Marker::H => Trans::H(self),
}
}
}