wrote test for matix multiplication

This commit is contained in:
Jon Janzen
2021-03-28 18:29:18 -06:00
parent c47d3448a3
commit 6fd1eb49b7
2 changed files with 25 additions and 1 deletions

View File

@@ -8,4 +8,3 @@ edition = "2018"
[dependencies]
approx = "0.4"
bencher = "0.1.5"

View File

@@ -169,4 +169,29 @@ mod tests {
assert_ne!(m_a, m_b);
}
#[test]
fn multiply() {
let matrix_a = Matrix::from_array([
[1.0, 2.0, 3.0, 4.0,],
[5.0, 6.0, 7.0, 8.0,],
[9.0, 8.0, 7.0, 6.0,],
[5.0, 4.0, 3.0, 2.0,],
]);
let matrix_b = Matrix::from_array([
[-2.0, 1.0, 2.0, 3.0,],
[3.0, 2.0, 1.0, -1.0,],
[4.0, 3.0, 6.0, 5.0,],
[1.0, 2.0, 7.0, 8.0,],
]);
let expected = Matrix::from_array([
[20.0, 22.0, 50.0, 48.0],
[44.0, 54.0, 114.0, 108.0],
[40.0, 58.0, 110.0, 102.0,],
[16.0, 26.0, 46.0, 42.0],
]);
assert_eq!(matrix_a * matrix_b, expected);
}
}