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
use crate::matrix_expression::MatrixExpression;
use crate::usize2::USize2;
pub struct Matrix<const M: usize, const N: usize, const TOTAL: usize> {
_elements: [f64; TOTAL],
}
impl<const M: usize, const N: usize, const TOTAL: usize> MatrixExpression for Matrix<M, N, TOTAL> {
fn size(&self) -> USize2 {
return USize2::new(M, N);
}
fn rows(&self) -> usize {
return M;
}
fn cols(&self) -> usize {
return N;
}
fn eval(&self, x: usize, y: usize) -> f64 {
return self._elements[x * N + y];
}
}