use super::{super::Matrix, SquareMatrix, Vector};
use crate::math::test::{TestError, assert_eq};
fn vector_dim_6() -> Vector {
Vector::from([2.0, 1.0, 3.0, 2.0, 1.0, 3.0])
}
fn matrix_dim_6_9() -> Matrix {
[
Vector::from([2.0, 2.0, 4.0, 0.0, 0.0, 1.0, 1.0, 3.0, 3.0]),
Vector::from([0.0, 3.0, 1.0, 0.0, 0.0, 1.0, 4.0, 2.0, 1.0]),
Vector::from([3.0, 0.0, 1.0, 2.0, 0.0, 3.0, 4.0, 4.0, 2.0]),
Vector::from([4.0, 4.0, 0.0, 2.0, 1.0, 1.0, 0.0, 0.0, 4.0]),
Vector::from([0.0, 1.0, 0.0, 1.0, 1.0, 3.0, 0.0, 1.0, 1.0]),
Vector::from([4.0, 2.0, 3.0, 4.0, 2.0, 4.0, 3.0, 0.0, 4.0]),
]
.into_iter()
.collect()
}
fn square_matrix_dim_9() -> SquareMatrix {
SquareMatrix::from([
[2.0, 2.0, 4.0, 0.0, 0.0, 1.0, 1.0, 3.0, 3.0],
[0.0, 3.0, 1.0, 0.0, 0.0, 1.0, 4.0, 2.0, 1.0],
[3.0, 0.0, 1.0, 2.0, 0.0, 3.0, 4.0, 4.0, 2.0],
[4.0, 4.0, 0.0, 2.0, 1.0, 1.0, 0.0, 0.0, 4.0],
[0.0, 1.0, 0.0, 1.0, 1.0, 3.0, 0.0, 1.0, 1.0],
[4.0, 2.0, 3.0, 4.0, 2.0, 4.0, 3.0, 0.0, 4.0],
[1.0, 3.0, 2.0, 0.0, 0.0, 0.0, 2.0, 4.0, 2.0],
[2.0, 2.0, 2.0, 4.0, 1.0, 2.0, 4.0, 2.0, 2.0],
[1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 4.0, 2.0, 1.0],
])
}
fn other_square_matrix_dim_9() -> SquareMatrix {
SquareMatrix::from([
[0.0, 4.0, 2.0, 0.0, 1.0, 4.0, 2.0, 4.0, 1.0],
[1.0, 2.0, 2.0, 1.0, 0.0, 3.0, 0.0, 2.0, 0.0],
[3.0, 0.0, 2.0, 3.0, 3.0, 0.0, 0.0, 0.0, 2.0],
[2.0, 3.0, 0.0, 0.0, 1.0, 3.0, 3.0, 4.0, 2.0],
[0.0, 4.0, 1.0, 3.0, 1.0, 1.0, 1.0, 2.0, 1.0],
[1.0, 3.0, 0.0, 3.0, 3.0, 2.0, 1.0, 3.0, 4.0],
[0.0, 0.0, 0.0, 1.0, 0.0, 3.0, 1.0, 3.0, 4.0],
[2.0, 0.0, 4.0, 3.0, 1.0, 2.0, 0.0, 3.0, 4.0],
[4.0, 2.0, 0.0, 0.0, 4.0, 0.0, 4.0, 2.0, 2.0],
])
}
fn get_vector_mul_matrix_dim_6_9() -> Vector {
Vector::from([33.0, 22.0, 21.0, 23.0, 9.0, 29.0, 27.0, 21.0, 34.0])
}
fn get_square_matrix_mul_other_square_matrix_dim_9() -> SquareMatrix {
SquareMatrix::from([
[33.0, 21.0, 28.0, 27.0, 32.0, 25.0, 18.0, 33.0, 36.0],
[15.0, 11.0, 16.0, 19.0, 12.0, 27.0, 9.0, 29.0, 32.0],
[26.0, 31.0, 24.0, 28.0, 29.0, 44.0, 27.0, 57.0, 57.0],
[25.0, 45.0, 17.0, 10.0, 26.0, 37.0, 32.0, 45.0, 21.0],
[12.0, 20.0, 7.0, 16.0, 16.0, 15.0, 11.0, 22.0, 21.0],
[39.0, 60.0, 20.0, 32.0, 47.0, 53.0, 45.0, 69.0, 56.0],
[25.0, 14.0, 28.0, 23.0, 19.0, 27.0, 12.0, 32.0, 33.0],
[30.0, 38.0, 21.0, 27.0, 29.0, 47.0, 31.0, 58.0, 51.0],
[28.0, 25.0, 20.0, 24.0, 23.0, 40.0, 23.0, 47.0, 45.0],
])
}
#[test]
fn vector_mul_matrix_dim_6_9() -> Result<(), TestError> {
assert_eq(
&(&vector_dim_6() * &matrix_dim_6_9()),
&get_vector_mul_matrix_dim_6_9(),
)
}
#[test]
fn square_matrix_mul_other_square_matrix_dim_9() -> Result<(), TestError> {
assert_eq(
&(square_matrix_dim_9() * other_square_matrix_dim_9()),
&get_square_matrix_mul_other_square_matrix_dim_9(),
)
}