Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify 2-d matrix types #260

Open
plafer opened this issue Mar 14, 2024 · 0 comments
Open

Simplify 2-d matrix types #260

plafer opened this issue Mar 14, 2024 · 0 comments

Comments

@plafer
Copy link
Contributor

plafer commented Mar 14, 2024

There are currently multiple types representing 2 dimensional matrices: Vec<Vec<E>>, RowMatrix, ColMatrix, and maybe others. I suggest we only have 2: RowMajorMatrix and ColumnMajorMatrix.

  • Each have an internal data buffer, similar to what today's RowMatrix has
  • In each, you can read/write rows and columns; only one of which would be most cache efficient (e.g. RowMajorMatrix would have read/writing rows fastest).
  • The entire codebase would use these - you would never see Vec<Vec<E>>. For example, EvaluationFragment::update_row() would simply delegate to the internal ColumnMajorMatrix as opposed to (re-)implementing that logic there.

The main benefits of this approach are:

  • readability: I don't need to wonder if Vec<Vec<E>> stores columns or rows
  • reusability: any custom logic across the codebase for Vec<Vec<E>> (such as this EvaluationFragment::update_row(), ColMatrix, RowMatrix) would all live in one place
  • performance: these are more performant than Vec<Vec<E>> (cache locality)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant