[Jama] Observation on det() function

15 views
Skip to first unread message

Harika N

unread,
May 24, 2017, 1:30:08 AM5/24/17
to ja...@list.nist.gov
Dear Authors,

I have noticed that the determinant function in the JAMA library is
giving incorrect results for
few inputs.

For example:

Consider the Matrix

1 0 1 0 1 1 1
0 0 1 1 1 0 1
1 0 0 1 1 1 0
0 1 0 1 1 1 1
0 0 1 0 0 0 1
1 1 1 0 0 0 1
1 1 0 0 1 1 1

The determinant for the above matrix is 1 where as the library
function det() is giving the result as 0.9999999999999998. Please
correct me if there is some problem with the function usage.

Thanks.


--
Regards,
Harika

Ronald Boisvert

unread,
May 24, 2017, 11:21:16 AM5/24/17
to ja...@list.nist.gov
While it is clear that the determinant of an integer matrix should be an integer, Jama, treats it as a real general matrix, and hence all of the integers are stored as reals. Also, Jama does not use the straightforward definition of a determinant to compute it. That, it turns out, becomes terribly inefficient (and inaccurate) as the order of the matrix increases. Instead, Jama first performs an LU decomposition of the matrix, and then uses the diagonals of the two factors to compute the determinant. See, for example, https://en.wikipedia.org/wiki/LU_decomposition. Because computing the decomposition requires some divisions, the intermediate results are not integers, and, because floating-point arithmetic is not exact, some representation and round-off errors occur. The result you display below is as good as one can expect in double-precision floating point.

Ron

Tobias Weimer

unread,
May 24, 2017, 11:23:15 AM5/24/17
to ja...@list.nist.gov
An HTML attachment was scrubbed...
Reply all
Reply to author
Forward
0 new messages