octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #51270] isdefinite should return 0 for zero ma


From: Travis Arnold
Subject: [Octave-bug-tracker] [bug #51270] isdefinite should return 0 for zero matrices
Date: Tue, 20 Jun 2017 12:49:44 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36

Follow-up Comment #3, bug #51270 (project octave):

Marco is correct. A zero matrix is positive semidefinite, so


isdefinite(zeros(n))


should return 0 for any integer n. My patch fixes this.

Marco is also correct that


[1, 0; 0, 0]


is positive semidefinite, and so perhaps it would be desirable for 


isdefinite ([1, 0; 0, 0], 0)


to return 0.

The way the code works is by attempting a series of Cholesky decompositions
(https://en.wikipedia.org/wiki/Cholesky_decomposition). Note that
theoretically, a Cholesky decomposition exists for any positive semidefinite
matrix, but it is only unique for strictly positive definite matrices. In
practice however,


[r, p] = chol(A)


calculates the Cholesky decomposition successfully only if A is strictly
positive definite. If this returns a nonzero p, this indicates that the
decomposition was unsuccessful and so A is not strictly positive definite.

We want the code to tell us whether a matrix A is 

* strictly positive definite
* positive semidefinite
* neither

What it actually checks for is this:

* Are all of the eigenvalues of A at least tol bigger than 0? If so then tell
the user that A is strictly positive definite.
* If not, then are all of the eigenvalues of A + tol bigger than 0? If so then
tell the user that the A is positive semidefinite.
* If not, then tell the user that A is neither strictly positive definite nor
positive semidefinite.

The problem comes from specifying a tolerance of 0. Regarding


isdefinite ([1, 0; 0, 0], 0)


the eigenvalues are not at least tol bigger than 0, so the code does not
return strictly positive definite. Also, the eigenvalues + tol are not bigger
than zero, so the code does not return positive semidefinite. So the code
returns the third option: neither.

Calling the function with a tolerance of 0 is probably bad practice in
general, so I'm not sure you want to account for that use case. Clarifying the
documentation or throwing a warning if the user tries to use a tolerance of 0
might be a good idea.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51270>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]