Skip to content
Snippets Groups Projects
Commit 3808cada authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

refactor linalg tests (dragoon/komodo!29)

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
```rust
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
```rust
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
```rust
Matrix::<Fr>::from_diagonal(vec![Fr::from(2), Fr::from(3), Fr::from(4)])
```
becomes
```rust
Matrix::<Fr>::from_diagonal(vec_to_elements(vec![2, 3, 4]))
```
parent b6d70cc8
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment