Condense sparsity pattern: don't check if entries already exist #550
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.
After #436 the condensation of the pattern is done by creating a new matrix which is added to the original matrix. Before this patch there is still a check for whether each new entry already exist in the original matrix before adding it to the new matrix. With the new approach implemented in #436 this seems unnecessary and this patch removes the check. This also removes some extra complexity from the code.
A datapoint, which support this, is the Stoke's flow example in the documentation. In that problem, the condensation adds 32k new entries, of which 30k are new, and 2k exist in the original matrix. Checking whether the 32k elements exist is much more expensive than simply including the extra 2k entries in the new matrix. The new approach reduces the time for creating the combined matrix from 4ms to 3.2ms.
Matrix creation isn't a bottleneck by any means, but it is nice to see that we with simpler code also get better performance.