-
Notifications
You must be signed in to change notification settings - Fork 45
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
SparseCostMatrix #348
Merged
Merged
SparseCostMatrix #348
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ize array internally Instead of using Vec<u8>, LocalCostMatrix now holds a [u8; 2500] directly. Also replaced the Into<Vec<u8>> for LocalCostMatrix with From<LocalCostMatrix> for Vec<u8>, to be idiomatic.
LocalCostMatrix's can now be indexed by (u8, u8) pairs.
Before, we just relied on the bounds checking the index that pos_as_idx spits out, but that allows invalid coordinates like (0, 201) to be passed in. This fixes that. As a result of the bounds checking from the asserts, we can skip the checking that goes on in []::index, and just use the unchecked versions instead.
…ses unchecked internally With the (u8, u8) indexing impl, we can rewrite get and set in terms of them. And in the indexing impl, because we check that x and y are in bounds, we're guaranteed that the index from pos_as_idx will be in bounds as well, so we can just use the unchecked accessors instead.
…trix::{iter, iter_mut} SparseCostMatrix is the sparse counterpart to the LocalCostMatrix. Also added methods for generating iterators over both the sparse and dense versions.
Can now merge the two cost matrix types into each other; forms the basis for possible layered cost matrix behaviour, builder patterns, etc.
…es back instead of u8 Some users might only care about a few values, why deref before it's needed? They can always chain .copied() after if needed. BREAKING CHANGE: .iter() returns impl Iterator<Item = ((u8, u8), &u8)> instead of impl Iterator<Item = ((u8, u8), u8)> for Local and SparseCostMatrix.
…n::y to u8 Now that the position change is merged, these casts are unnecessary.
Azaril
requested changes
Apr 18, 2021
Azaril
approved these changes
Apr 19, 2021
Azaril
approved these changes
Apr 19, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a basic implementation of a sparse cost matrix. Also adds iter and iter_mut to LocalCostMatrix.
Built on top of #347, should probably wait for that to merge and then I can rebase.