You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Phil Steitz (JIRA)" <ji...@apache.org> on 2009/09/20 16:33:15 UTC

[jira] Created: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Eigenvector computation incorrectly returning vectors of NaNs
-------------------------------------------------------------

                 Key: MATH-297
                 URL: https://issues.apache.org/jira/browse/MATH-297
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 2.0
            Reporter: Phil Steitz
             Fix For: 2.1


As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:

{code}
public void testEigenDecomposition() {
    double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
    RealMatrix rm = new Array2DRowRealMatrix(m);
    assertEquals(rm.toString(),
        "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
    EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
        MathUtils.SAFE_MIN);
    RealVector rv0 = ed.getEigenvector(0);
    assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
  }
{code}

ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Bill Barker (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12767159#action_12767159 ] 

Bill Barker commented on MATH-297:
----------------------------------

This is now fixed as of R826550.  Unfortunately, I lack karma to resolve this issue, so will have to hope that somebody else will resolve it for me.

> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luc Maisonobe resolved MATH-297.
--------------------------------

    Resolution: Fixed

The original issue as been solved 2009-11-29 as of r885268.
The remaining problem identified in the last comments has been moved in a separate JIRA issue: MATH-333

> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Bruce A Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770367#action_12770367 ] 

Bruce A Johnson commented on MATH-297:
--------------------------------------

There still seems to be a problem with the decomposition of some matrices.  For example, the decomposition of the identity matrix {{1,0},{0,1}} yields the correct eigenvalues, but NaN for all the eigenvector elements.
Crucially, the "isIncludedColumn" in the EigenDecompositionImplTest.java file always returns true (at least on my system) when the calculated eigenvectors have NaN elements, so is useless as a test for this problem.

Also, I discovered this problem when getting NaN values doing an SVD of certain matrices (where each row has only one non-zero value).  Since the SVD algorithm uses the EigenDecompositionImpl code, this seems to be a result of this current  bug.  (And ironically, I just told my students that one reason people love the SVD is that it essentially never fails).







> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Bruce A Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770367#action_12770367 ] 

Bruce A Johnson edited comment on MATH-297 at 10/27/09 3:19 AM:
----------------------------------------------------------------

There still seems to be a problem with the decomposition of some matrices.  For example, the decomposition of the identity matrix {noformat} {{1,0},{0,1}}{noformat}
 yields the correct eigenvalues, but NaN for all the eigenvector elements.
Crucially, the "isIncludedColumn" in the EigenDecompositionImplTest.java file always returns true (at least on my system) when the calculated eigenvectors have NaN elements, so is useless as a test for this problem.

Also, I discovered this problem when getting NaN values doing an SVD of certain matrices (where each row has only one non-zero value).  Since the SVD algorithm uses the EigenDecompositionImpl code, this seems to be a result of this current  bug.  (And ironically, I just told my students that one reason people love the SVD is that it essentially never fails).







      was (Author: bjohnson):
    There still seems to be a problem with the decomposition of some matrices.  For example, the decomposition of the identity matrix '{{1,0},{0,1}}' yields the correct eigenvalues, but NaN for all the eigenvector elements.
Crucially, the "isIncludedColumn" in the EigenDecompositionImplTest.java file always returns true (at least on my system) when the calculated eigenvectors have NaN elements, so is useless as a test for this problem.

Also, I discovered this problem when getting NaN values doing an SVD of certain matrices (where each row has only one non-zero value).  Since the SVD algorithm uses the EigenDecompositionImpl code, this seems to be a result of this current  bug.  (And ironically, I just told my students that one reason people love the SVD is that it essentially never fails).






  
> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12783480#action_12783480 ] 

Luc Maisonobe commented on MATH-297:
------------------------------------

Another step towards the solution has been checked in as of r885268.
Just as Bruce noticed one month ago (thanks), there was an improvement in dstqds and dqds algorithms implemented in DLAR1V that are not in Dhillon's thesis.
The problem is still not completely solved as for example in dimension 3 the decomposition of identity leads to 3 times the same
vector (0, 0, 1) instead of giving (1, 0, 0), (0, 1, 0) and (0, 0, 1).

> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Jake Mannix (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12772913#action_12772913 ] 

Jake Mannix commented on MATH-297:
----------------------------------

Doing the most trivial fix possible (dividing by the SAFE_MIN if diPl == 0)  on the line which leads to NaN appears to correctly fix this for the particular case of decomposing diagonal matrices (at least for 2x2 and 3x3 cases I checked with a unit test). 

I'm not sure if this "fixes" the problem, because I'm not sure if I really grok the algorithm's implementation in this code.

We could see better if I knew how often this pops up (any matrix whose tri-diagonal form is actually diagonal?)...

> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Bruce A Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770601#action_12770601 ] 

Bruce A Johnson commented on MATH-297:
--------------------------------------

..., and I note that what I presume to be the original Fortran code (in dlar1v.f of LAPACK) has several sections of code marked:

*        Runs a slower version of the above loop if a NaN is detected

Hope this helps in resolving the issue,

Bruce


> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Bruce A Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770367#action_12770367 ] 

Bruce A Johnson edited comment on MATH-297 at 10/27/09 3:16 AM:
----------------------------------------------------------------

There still seems to be a problem with the decomposition of some matrices.  For example, the decomposition of the identity matrix '{{1,0},{0,1}}' yields the correct eigenvalues, but NaN for all the eigenvector elements.
Crucially, the "isIncludedColumn" in the EigenDecompositionImplTest.java file always returns true (at least on my system) when the calculated eigenvectors have NaN elements, so is useless as a test for this problem.

Also, I discovered this problem when getting NaN values doing an SVD of certain matrices (where each row has only one non-zero value).  Since the SVD algorithm uses the EigenDecompositionImpl code, this seems to be a result of this current  bug.  (And ironically, I just told my students that one reason people love the SVD is that it essentially never fails).







      was (Author: bjohnson):
    There still seems to be a problem with the decomposition of some matrices.  For example, the decomposition of the identity matrix "{{1,0},{0,1}}" yields the correct eigenvalues, but NaN for all the eigenvector elements.
Crucially, the "isIncludedColumn" in the EigenDecompositionImplTest.java file always returns true (at least on my system) when the calculated eigenvectors have NaN elements, so is useless as a test for this problem.

Also, I discovered this problem when getting NaN values doing an SVD of certain matrices (where each row has only one non-zero value).  Since the SVD algorithm uses the EigenDecompositionImpl code, this seems to be a result of this current  bug.  (And ironically, I just told my students that one reason people love the SVD is that it essentially never fails).






  
> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770424#action_12770424 ] 

Luc Maisonobe commented on MATH-297:
------------------------------------

I will look at this issue one issu MATH-308 has been solved.

> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz closed MATH-297.
----------------------------


> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Bruce A Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770474#action_12770474 ] 

Bruce A Johnson commented on MATH-297:
--------------------------------------

Thanks.

The problem seems to be a divide by zero error with the variable diP1 in the following code, but this is probably as far as I'll get in debugging it:
{noformat}
   private void stationaryQuotientDifferenceWithShift(final double[] d, final double[] l,
                                                       final double lambda) {
        final int nM1 = d.length - 1;
        double si = -lambda;
        for (int i = 0, sixI = 0; i < nM1; ++i, sixI += 6) {
            final double di   = d[i];
            final double li   = l[i];
            final double diP1 = di + si;
            final double liP1 = li * di / diP1;
            work[sixI]        = si;
            work[sixI + 1]    = diP1;
            work[sixI + 2]    = liP1;
            si = li * liP1 * si - lambda;
        }
        work[6 * nM1 + 1] = d[nM1] + si;
        work[6 * nM1]     = si;
    }
{noformat}

> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Jake Mannix (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12772924#action_12772924 ] 

Jake Mannix commented on MATH-297:
----------------------------------

Ok, well sadly it's easy to find an example which *isn't* fixed by just removing that one divide-by-zero: 
{code} { {0, 1, 0}, {1, 0, 0}, {0, 0, 1} } {code} leads to perfectly reasonable eigenvalues (1, 1, -1), but NaN again rears its ugly head because findEigenVectors() assumes that, among other things, that the main diagonal does not start with a zero, and then divides by it.

Not sure what the proper solution is to this, but a non-shifted LDL^t decomposition is a lot easier to understand to me than the other place where the NaN pops up, so maybe I can figure this one out on the plane ride down to ApacheCon tomorrow.

> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Bruce A Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770367#action_12770367 ] 

Bruce A Johnson edited comment on MATH-297 at 10/27/09 3:16 AM:
----------------------------------------------------------------

There still seems to be a problem with the decomposition of some matrices.  For example, the decomposition of the identity matrix "{{1,0},{0,1}}" yields the correct eigenvalues, but NaN for all the eigenvector elements.
Crucially, the "isIncludedColumn" in the EigenDecompositionImplTest.java file always returns true (at least on my system) when the calculated eigenvectors have NaN elements, so is useless as a test for this problem.

Also, I discovered this problem when getting NaN values doing an SVD of certain matrices (where each row has only one non-zero value).  Since the SVD algorithm uses the EigenDecompositionImpl code, this seems to be a result of this current  bug.  (And ironically, I just told my students that one reason people love the SVD is that it essentially never fails).







      was (Author: bjohnson):
    There still seems to be a problem with the decomposition of some matrices.  For example, the decomposition of the identity matrix {{1,0},{0,1}} yields the correct eigenvalues, but NaN for all the eigenvector elements.
Crucially, the "isIncludedColumn" in the EigenDecompositionImplTest.java file always returns true (at least on my system) when the calculated eigenvectors have NaN elements, so is useless as a test for this problem.

Also, I discovered this problem when getting NaN values doing an SVD of certain matrices (where each row has only one non-zero value).  Since the SVD algorithm uses the EigenDecompositionImpl code, this seems to be a result of this current  bug.  (And ironically, I just told my students that one reason people love the SVD is that it essentially never fails).






  
> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-297) Eigenvector computation incorrectly returning vectors of NaNs

Posted by "Axel Kramer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12767433#action_12767433 ] 

Axel Kramer commented on MATH-297:
----------------------------------

If I'm expanding my testcase to the snippet below, I'm  now getting an eigenvector with all "negative values" at index 1.
I think this should be avoided. 
See also the solution computed by Ted Dunning on the mailing list: 
http://www.mail-archive.com/dev@commons.apache.org/msg12038.html

    double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0, 0.0, 1.0 } };
    RealMatrix rm = new Array2DRowRealMatrix(m);
    assertEquals(rm.toString(),
        "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
    EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
        MathUtils.SAFE_MIN);
    RealVector rv0 = ed.getEigenvector(0);
    RealVector rv1 = ed.getEigenvector(1);
    RealVector rv2 = ed.getEigenvector(2);
    assertEquals(rv0.toString(), "{0,58; 0,58; -0,58}");
    assertEquals(rv1.toString(), "{-0; -0,71; -0,71}");
    assertEquals(rv2.toString(), "{0,82; -0,41; 0,41}");


> Eigenvector computation incorrectly returning vectors of NaNs
> -------------------------------------------------------------
>
>                 Key: MATH-297
>                 URL: https://issues.apache.org/jira/browse/MATH-297
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Phil Steitz
>             Fix For: 2.1
>
>
> As reported by Axel Kramer on commons-dev, the following test case succeeds, but should fail:
> {code}
> public void testEigenDecomposition() {
>     double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,0.0, 1.0 } };
>     RealMatrix rm = new Array2DRowRealMatrix(m);
>     assertEquals(rm.toString(),
>         "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>     EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>         MathUtils.SAFE_MIN);
>     RealVector rv0 = ed.getEigenvector(0);
>     assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>   }
> {code}
> ed.getRealEigenvalues() returns the correct eigenvalues (2, 1, -1), but all three eigenvectors contain only NaNs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.