refactor linalg tests
in this MR, i define the following two functions in linalg::tests
vec_to_elements<T: Field>(elements: Vec<u128>) -> Vec<T>
mat_to_elements<T: Field>(mat: Vec<Vec<u128>>) -> Vec<Vec<T>>
the idea is to help see what the matrices and vectors are at a glance, without too much processing.
the end result is that all Fr::from(<some number>)
are gone
example
- a full matrix
Matrix::from_vec_vec(vec![
vec![Fr::from(2), Fr::zero(), Fr::zero()],
vec![Fr::zero(), Fr::from(3), Fr::zero()],
vec![Fr::zero(), Fr::zero(), Fr::from(4)],
vec![Fr::from(2), Fr::from(3), Fr::from(4)],
])
becomes
Matrix::<Fr>::from_vec_vec(mat_to_elements(vec![
vec![2, 0, 0],
vec![0, 3, 0],
vec![0, 0, 4],
vec![2, 3, 4],
]))
which is hopefully easier to read and understand what the matrix is.
- a diagonal one
Matrix::<Fr>::from_diagonal(vec![Fr::from(2), Fr::from(3), Fr::from(4)])
becomes
Matrix::<Fr>::from_diagonal(vec_to_elements(vec![2, 3, 4]))