Compare Cholesky and BunchKaufman by properties #54509
Merged
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.
The fields of a
Factorization
are more of an implementation detail, and a factorization is usually uniquely identified by its properties. Therefore, it makes sense to check if twoFactorizaiton
s are equal by comparing their properties. I've implemented this forCholesky
andBunchKaufman
, as these are the ones where the properties are wrappers around the field arrays, and therefore their values differ.In particular, this would make such comparisons work even if the parents of the
AbstractTriangular
factors have uninitialized elements corresponding to the structural zeros of the triangular wrappers. Currently, this throws an error as it tries to compare the parents (which are the fields of theFactorization
objects), but this is unnecessary. What really matters is that the triangular factors are equal.This will make the comparisons slower in general, as new arrays may need to be allocated or computed. However, comparing two
Factorization
objects is probably unlikely to feature in a performance-sensitive path, and is perhaps more likely to feature in tests.