Issue Details (XML | Word | Printable)

Key: MATH-274
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Luc Maisonobe
Reporter: Manuel Rossetti
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Math

testing for symmetric positive definite matrix in CholeskyDecomposition

Created: 04/Jun/09 07:24 PM   Updated: 07/Aug/09 09:16 AM
Return to search
Component/s: None
Affects Version/s: 2.0
Fix Version/s: 2.0

Time Tracking:
Not Specified

Environment: Mac OS X, NetBeans

Resolution Date: 04/Jun/09 08:11 PM


 Description  « Hide
I used this matrix:

double[][] cv = {
{0.40434286, 0.09376327, 0.30328980, 0.04909388},
{0.09376327, 0.10400408, 0.07137959, 0.04762857},
{0.30328980, 0.07137959, 0.30458776, 0.04882449},
{0.04909388, 0.04762857, 0.04882449, 0.07543265}
};

And it works fine, because it is symmetric positive definite

I tried this matrix:

double[][] cv = {
{0.40434286, -0.09376327, 0.30328980, 0.04909388},
{-0.09376327, 0.10400408, 0.07137959, 0.04762857},
{0.30328980, 0.07137959, 0.30458776, 0.04882449},

{0.04909388, 0.04762857, 0.04882449, 0.07543265}

};

And it should throw an exception but it does not. I tested the matrix in R and R's cholesky decomposition method returns that the matrix is not symmetric positive definite.

Obviously your code is not catching this appropriately.

By the way (in my opinion) the use of exceptions to check these conditions is not the best design or use for exceptions. If you are going to force the use to try and catch these exceptions at least provide methods to test the conditions prior to the possibility of the exception.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #781845 Thu Jun 04 20:07:29 UTC 2009 luc fixed detection of not positive definite matrices
JIRA: MATH-274
Files Changed
MODIFY /commons/proper/math/trunk/src/site/xdoc/changes.xml
MODIFY /commons/proper/math/trunk/src/test/org/apache/commons/math/linear/CholeskyDecompositionImplTest.java
MODIFY /commons/proper/math/trunk/src/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java

Luc Maisonobe added a comment - 04/Jun/09 08:11 PM
fixed in subversion repository as of r 781845
Concerning the exception, it is not possible to check the matrix without trying to decompose it, so providing an external check would be a waste as it would already do almost everything. In fact, it was exactly the reason for the bug: the check was done too early on the raw matrix, not on the matrix after some changes have been made to its elements.
thanks for the report

Luc Maisonobe made changes - 04/Jun/09 08:11 PM
Field Original Value New Value
Resolution Fixed [ 1 ]
Assignee Luc Maisonobe [ luc ]
Status Open [ 1 ] Resolved [ 5 ]
Manuel Rossetti added a comment - 04/Jun/09 08:57 PM
Luc,

Thanks for fixing the error.

You are missing my point. You should provide the user the opportunity
to check the condition, rather than having to rely on exceptions. The
client can make the decision whether it is a waste or not.

And, we will agree to disagree on how the library is using exceptions.

Regards,
Manuel

-----------------------------------------------------
Manuel D. Rossetti, Ph.D., P.E.
Associate Professor of Industrial Engineering
University of Arkansas
Department of Industrial Engineering
4207 Bell Engineering Center
Fayetteville, AR 72701
Phone: (479) 575-6756
Fax: (479) 575-8431
email: rossetti@uark.edu
www: www.uark.edu/~rossetti


Luc Maisonobe added a comment - 07/Aug/09 09:16 AM
closing resolved issue for 2.0 release

Luc Maisonobe made changes - 07/Aug/09 09:16 AM
Status Resolved [ 5 ] Closed [ 6 ]