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
use std::ops::Sub;
use crate::Matrix;
use super::matrix_init;
pub trait MSub<Rhs: Matrix>: Matrix
where
Self::Output: Matrix
{
type Output;
fn sub(self, rhs: Rhs) -> Self::Output;
}
impl<T1, T2, const H: usize, const L: usize> MSub<[[T2; L]; H]> for [[T1; L]; H]
where
Self: Matrix,
[[T2; L]; H]: Matrix,
[[<T1 as Sub<T2>>::Output; L]; H]: Matrix,
T1: Sub<T2> + Clone,
T2: Clone
{
type Output = [[<T1 as Sub<T2>>::Output; L]; H];
fn sub(self, rhs: [[T2; L]; H]) -> Self::Output
{
matrix_init(|r, c| self[r][c].clone() - rhs[r][c].clone())
}
}