Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

"Index out of bounds" error in SingularValueDecomposition.Solve #614

Closed
ChristerModin opened this issue May 26, 2017 · 5 comments
Closed

Comments

@ChristerModin
Copy link

Hi

First thanks a lot for all your work with this, at it seems, amazing library :)

I've run into trouble though when fitting an overdetermined system with a two-dimensional B-matrix.
Seems as the VLU isn't dimensioned properly with respect to the number of rows in U
Also, the inner loop should have the number of columns in U as upper bound instead of urows.

I suggest from line 934 in SingularValueDecomposition.cs :

        int ucols = u.Columns();
        var VLU = new Double[vrows, urows];
        for (int i = 0; i < vrows; i++)
        {
            for (int j = 0; j < urows; j++)
            {
                Double sum = 0;
                for (int k = 0; k < ucols; k++)
                    sum += VL[i, k] * u[j, k];
                VLU[i, j] = sum;
            }
        }         

BR

Christer Modin

@cesarsouza
Copy link
Member

Hi Christer,

Many thanks for opening the issue! Can you please provide a sample matrix that triggers the problem so I can write an unit test for it?

Regards,
Cesar

@ChristerModin
Copy link
Author

ChristerModin commented Jun 7, 2017 via email

@ndcomplete
Copy link

This is very similar to the question I asked previously, which also includes a sample. I'm not sure if the sample provided will highlight the problem, as it is for JaggedSingularValueDecomposition, though I think it's the same underlying issue:

#602

@ChristerModin
Copy link
Author

Yep, seems to be similar code with the same issue for all versions of svd-decomposition-solve where B isn't one-dimensional.

@cesarsouza
Copy link
Member

Fixed in release 3.6.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants