jingyuzhu / efficient-java-matrix-library

Automatically exported from code.google.com/p/efficient-java-matrix-library
0 stars 0 forks source link

MatrixFeatures.isPositiveDefinite() modifies matrix although JavaDoc states otherwise #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
SimpleMatrix matrix = new SimpleMatrix(new double[][] { { 2, 0 }, { 0, 2 } });
matrix.print();
System.out.println("is pd? " + 
MatrixFeatures.isPositiveDefinite(matrix.getMatrix()));
matrix.print();

What is the expected output? What do you see instead?
Expected:
Type = dense , numRows = 2 , numCols = 2
 2,000   0,000  
 0,000   2,000  
is pd? true
Type = dense , numRows = 2 , numCols = 2
 2,000   0,000  
 0,000   2,000  

Actual:
Type = dense , numRows = 2 , numCols = 2
 2,000   0,000  
 0,000   2,000  
is pd? true
Type = dense , numRows = 2 , numCols = 2
 1,414   0,000  
 0,000   1,414  

What version of the product are you using? On what operating system?
EJML 0.21, Windows 7 Pro x64, Java 7u11 x64

Please provide any additional information below.
Maybe I misunderstand the description, but if I do, it's higly unintuitive 
nonetheless. I would expect an isXyz() method to not alter any parameters 
passed, esp. when it states so in the JavaDoc.

Original issue reported on code.google.com by eriklan.dodinh@gmail.com on 17 Jan 2013 at 8:41

GoogleCodeExporter commented 8 years ago
To solve this, maybe MatrixFeatures.isPositiveDefinite() should work with a 
copy of the original matrix when trying to do the Cholesky Decomposition. As a 
workaround, that's what I do atm.

Original comment by eriklan.dodinh@gmail.com on 17 Jan 2013 at 8:59

GoogleCodeExporter commented 8 years ago
That is a bug.  It was missing a check to lu.inputModified().  Fixed and 
committed to SVN.  Also found a few other cases where that flag was not being 
checked.  Let me know if you have any additional problems.

Original comment by peter.ab...@gmail.com on 17 Jan 2013 at 11:43

GoogleCodeExporter commented 8 years ago
That was quick, thanks!

Original comment by eriklan.dodinh@gmail.com on 18 Jan 2013 at 11:50