GenericLinearAlgebra.jl icon indicating copy to clipboard operation
GenericLinearAlgebra.jl copied to clipboard

Computing generalized eigenvalues

Open daanhb opened this issue 2 years ago • 4 comments

This is the PR mentioned in #126 and based on code provided to me by @thijssteel.

It implements eigval(A, B) for generic matrices A and B using the QZ algorithm. Copying a comment from the code:

Two orthogonal matrices Q and Z are constructed to reduce the "pencil" (A,B) to another form Q'*(A,B)*Z:

  • in a first step A and B are reduced to upper Hessenberg and upper triangular form, respectively (see: hesstriangular)
  • next a generalized Schur decomposition further reduces both matrices to upper triangular form
  • the generalized eigenvalues are then given by the ratios of the diagonals of those two triangular matrices.

daanhb avatar Jun 03 '23 13:06 daanhb

I have yet to add tests. First I'm wondering whether this package is the right place to add this functionality and whether it's deemed useful. It is at least to me :-)

daanhb avatar Jun 03 '23 13:06 daanhb

Codecov Report

Patch coverage has no change and project coverage change: -23.35 :warning:

Comparison is base (27a78e0) 96.08% compared to head (6a5beeb) 72.74%.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #127       +/-   ##
===========================================
- Coverage   96.08%   72.74%   -23.35%     
===========================================
  Files          11       12        +1     
  Lines        1636     2161      +525     
===========================================
  Hits         1572     1572               
- Misses         64      589      +525     
Impacted Files Coverage Δ
src/GenericLinearAlgebra.jl 100.00% <ø> (ø)
src/eigen.jl 97.17% <ø> (ø)
src/qz.jl 0.00% <0.00%> (ø)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Jun 03 '23 14:06 codecov[bot]

Looking at this code, at other parts of GenericLinearAlgebra and at LinearAlgebra, I see many opportunities for better integration (and less code in total). For this PR:

  • reuse LinearAlgebra.floatmin2
  • better share code for Givens rotations, Householder reflections and eigenvalues of 2x2 blocks
  • make computation of eigenvalues more consistent. LinearAlgebra returns real eigenvalues when they are real, GenericLinearAlgebra always returns complex vectors (it seems?) and I've followed LinearAlgebra

It might make the implementation quite a bit shorter.

daanhb avatar Jun 03 '23 14:06 daanhb

I'm sorry for the silence here. This contributions is highly appreciated. I'm a bit stretched for the time being but will try to get this reviewed over the summer.

andreasnoack avatar Jun 20 '23 20:06 andreasnoack