Test and fix Singular Value Decomposition (double) at different scales#1146
Open
lellid wants to merge 1 commit intomathnet:masterfrom
Open
Test and fix Singular Value Decomposition (double) at different scales#1146lellid wants to merge 1 commit intomathnet:masterfrom
lellid wants to merge 1 commit intomathnet:masterfrom
Conversation
Author
|
One thing to add: I set the relative accuracy in the calls to Dirk |
This file contains hidden or 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
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.
Currently, Singular value decomposition gives wrong results if the numbers in the matrix are very small (1E-16 or smaller).
This PR adds a test for SVD at different scales (1, 1E40, 1E-40) and compares both the reconstructed matrix with the original matrix as well as the results with high precision results generated by Mathematica.
Svd (only the double version) was fixed by using an own version of the function
AlmostEqualRelative, which provides a really relative comparison method.In contrast, the method
AlmostEqualRelativeinPrecision.EqualitycallsAlmostEqualNormRelative, and in this method, there is a problematic section which decided on absolute differences instead of relative differences:The absolute comparsion is OK if the numbers are in the order of 1, which is the case for U and VT in SVD, but not for W.
Since
AreAlmostRelativeis abundantly used both in code and test, I suspect that more functions (and tests) are affected. If this PR is accepted, I can also add a test and fix the float version of SVD.Dirk