Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isPositiveSemiDefinite not accessible #10332

Closed
sagetrac-monniaux mannequin opened this issue Nov 25, 2010 · 15 comments
Closed

isPositiveSemiDefinite not accessible #10332

sagetrac-monniaux mannequin opened this issue Nov 25, 2010 · 15 comments

Comments

@sagetrac-monniaux
Copy link
Mannequin

sagetrac-monniaux mannequin commented Nov 25, 2010

I would like to test rational matrices for semidefinite positiveness. There is such a function in linbox, apparently (isPositiveSemiDefinite, from is-positive-semidefinite.h), but it is not accessible from Sage.

CC: @orlitzky @kliem @mwageringel @dimpase @rbeezer

Component: linear algebra

Keywords: psd, semidefinite positive

Author: Michael Orlitzky

Branch/Commit: 909c1e1

Reviewer: Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/10332

@orlitzky
Copy link
Contributor

comment:2

I went down a rabbit hole with the cholesky inverse and wound up here. The inverse of a positive-definite matrix can actually be computed a tiiiiny bit faster through the indefinite_factorization method, which returns a naive (suitable only in exact arithmetic) LDLT factorization.

If we modify the indefinite_factorization to pivot (put the zeros at the bottom of D), we could also perform an LDLT factorization for positive-SEMIdefinite matrices, making the goal of this ticket attainable.

Note also that some people have asked for square roots of PSD matrices in #23424 and #25464. Right now that's only implemented for positive-definite matrices, due to the aforementioned limitation of the LDLT factorization, so we could potentially improve that too.

@orlitzky
Copy link
Contributor

comment:3

I'm slowly working on a pivoted LDLT factorization at

http://gitweb.michael.orlitzky.com/?p=sage.d.git;a=blob;f=mjo/ldlt.py

At some point I will have to carefully check (unless someone has a reference) how it can be used to determine positive-semidefiniteness, especially with complex matrices.

@orlitzky
Copy link
Contributor

orlitzky commented Oct 7, 2020

Branch: u/mjo/ticket/10332

@orlitzky
Copy link
Contributor

orlitzky commented Oct 7, 2020

Author: Michael Orlitzky

@orlitzky
Copy link
Contributor

orlitzky commented Oct 7, 2020

Commit: b2b925e

@orlitzky
Copy link
Contributor

orlitzky commented Oct 7, 2020

comment:4

This is nearing presentability.

My branch has a numerically stable block-LDLT factorization that works for indefinite matrices and in inexact arithmetic. The cited paper shows why we can use it to determine positive-semidefiniteness: each 2x2 diagonal block corresponds to one positive and one negative eigenvalue, and Sylvester's inertia theorem handles the rest.. I've added an is_positive_semidefinite() method for matrices based on that.

Compared to is_positive_definite(), the new method...

  1. Doesn't distinguish between real/complex algorithms. We simply insist that the matrix be Hermitian (which is true of real symmetric matrices, of course), and always use conjugate_transpose(). This is not hugely expensive and cleans up the user interface a lot.
  2. Doesn't do any checks on the input matrix. So long as the matrix is Hermitian, you should be okay -- but you're in charge of checking that. Running if not A.is_hermitian()... on your own is a lot simpler than asking the method to check it for you, and then waiting to catch an exception. And when you want it to be fast, there's no need to disable the checks; it's already fast.

This could conceivably also be used to speed up solve_left and solve_right for Hermitian matrices.

@orlitzky
Copy link
Contributor

comment:5

Since I haven't changed anything in four months I guess this is ready for review.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 26, 2021

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

21e0454Trac #10332: add the Bunch/Kaufman block-LDLT reference.
b4196fdTrac #10332: add the Higham "Accuracy and Stability..." reference.
8cd9e60Trac #10332: add block_ldlt() method for matrices.
1143a11Trac #10332: cross-reference block_ldlt <-> indefinite_factorization.
909c1e1Trac #10332: add is_positive_semidefinite() method for matrices.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 26, 2021

Changed commit from b2b925e to 909c1e1

@orlitzky
Copy link
Contributor

comment:8

Rebased onto develop.

@dimpase
Copy link
Member

dimpase commented Jan 27, 2021

comment:9

matrix2.pyx is long overdue for splitting, it's 670K !!! (unless we aim for Guinness Book of Records, of course).

@dimpase
Copy link
Member

dimpase commented Jan 27, 2021

comment:10

otherwise, OK.

@dimpase
Copy link
Member

dimpase commented Jan 27, 2021

Reviewer: Dima Pasechnik

@orlitzky
Copy link
Contributor

comment:11

Thanks!

@fchapoton fchapoton added this to the sage-9.3 milestone Jan 30, 2021
@vbraun
Copy link
Member

vbraun commented Feb 20, 2021

Changed branch from u/mjo/ticket/10332 to 909c1e1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants