wrote test for matix multiplication
This commit is contained in:
@@ -8,4 +8,3 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
approx = "0.4"
|
approx = "0.4"
|
||||||
bencher = "0.1.5"
|
|
||||||
|
|||||||
@@ -169,4 +169,29 @@ mod tests {
|
|||||||
|
|
||||||
assert_ne!(m_a, m_b);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user