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

RectangularMatrix.SingularValueDecomposition fails in certain cases #56

Open
Alex-Konnen opened this issue Aug 26, 2019 · 3 comments
Open

Comments

@Alex-Konnen
Copy link

For the following matrix:

44.6667 -392.0000 -66.0000
-392.0000 3488.0000 504.0001
-66.0000 504.0001 216.0001

RectangularMatrix.SingularValueDecomposition throws:
Meta.Numerics.NonconvergenceException : The algorithm did not converge within the allowed number of iterations.

For slightly different matrix:
44.6667 -391.9633 -66.0000
-391.9633 3487.4401 503.8801
-66.0000 503.8801 216.0001

it converges.
Is it not so that a SVD exists for EACH matrix?

@dcwuser
Copy link
Owner

dcwuser commented Aug 2, 2020

It is true that SVD exists for all matrices. It is also thinkable that our algorithm to compute it could fail with a NonconvergenceException, since the algorithm we use (which is quite standard) is iterative and relies on numerical convergence. However, for the values you quote, I am unable to reproduce the described behavior. The following code executes for me without any exception, and produces a working SVD:

        RectangularMatrix M = new RectangularMatrix(new double[,] {
            { 44.6667,  -392.0000, -66.0000 },
            { -392.0000, 3488.0000, 504.0001 },
            { -66.0000, 504.0001, 216.0001 }
        });
        //M = M.Transpose;
        SingularValueDecomposition S = M.SingularValueDecomposition();

Note that I also tried with the transpose, in case we disagreed about column vs row ordering.

@dcwuser
Copy link
Owner

dcwuser commented Aug 2, 2020

If you can send me explicit code that fails, I would be happy to debug the behavior.

@Alex-Konnen
Copy link
Author

Hi dcwuser, thanks for your reply. Unfortunately, it is a bit ago that I encountered the situation and, afaik, i implemented SVD from some different library at that place which behaved more robustly with these data. I cannot reproduce all of it right now, but I will try to when I am back in office.

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

2 participants