suicao / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

Indexing bug in the Singular Value Decomposition algorithm #343

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

    SVD with a singular matrix:

    Matrix3x3 m = new Matrix3x3();            
    m.V00 = 3f; m.V01 = 3f; m.V02 = 2f;
    m.V10 = 2f; m.V11 = 2f; m.V12 = -3f;
    m.V20 = -2f; m.V21 = -2f; m.V22 = 1f;            
    Matrix3x3 matU, matV;
    Vector3 vecDiag;
    m.SVD(out matU, out vecDiag, out matV);

What is the expected output?

    Diagonal elements of about [5.86   0   3.69]
    and matrices U and V

What do you see instead?

    IndexOutOfRangeException

What version of the product are you using?

    2.2.4

Reason / Solution:

    In my opinion, line 270 of SVD.cs should be
        for ( j = 0; j < m; j++ )
    rather than
        for ( j = 1; j <= m; j++ )

Greetings.

Original issue reported on code.google.com by Matthias...@gmail.com on 25 Apr 2013 at 7:56

GoogleCodeExporter commented 9 years ago

Original comment by andrew.k...@gmail.com on 6 Mar 2014 at 3:15