plonky2
plonky2 copied to clipboard
Matrix type
A proposal for a simple matrix type that supports the following operations:
- Construction in a few ways
- From iterator of iterators
- From flat vector
- Using closure that initializes a matrix of
MaybeUninit
- Indexing by row (each row is a slice)
- Mutable and non-mutable iteration (the iterators yield slices, one per row)
- Transposition
- Cloning
A Box will also store the length of the buffer, which is redundant information since the matrix already stores a height and a width (although you're right that it's less redundant than a Vec).
This code does already use Box for allocation and deallocation, it just stores it in a decomposed format. Like, to allocate a Matrix, we get a Box (somehow) and then extract the pointer to the first element, which we then store. In drop, we construct a Box from the pointer and the buffer size (computed from height and width), which takes care of deallocation.
I'm happy to just store a Box if that's your strong preference, but it would mean redundant information, and all the possible inconsistencies/bugs that come with it.
This is really cool, I expect it to be a big improvement over Vec<Vec<_>>. Contiguous memory FTW! 🚀
Hello!
This PR has been open for a long time, please review and update as following:
- If this PR is no l longer relevant, close it.
- If this PR is relevant but not read, mark it as Draft and make a comment of what else needs to be done.
- Fix any issues and get it merged / reviewed by 10/27/2023.
If there's no update by 10/27/2023 this PR will be closed.
Let's close this since it's a central aspect of Plonky3, and doesn't seem worthwhile to rework a bunch of Plonky2 code also to work with matrices.