Skip to content

Add complex gges! - #53

Open
pablosanjose wants to merge 1 commit into
DynareJulia:mainfrom
pablosanjose:complex-gges
Open

pablosanjose wants to merge 1 commit into
DynareJulia:mainfrom
pablosanjose:complex-gges

Conversation

@pablosanjose

@pablosanjose pablosanjose commented Oct 26, 2026 •

Copy link
Copy Markdown

Great package, we've used it in Quantica.jl to save a ton of allocations. There are a couple of functionalities we were missing, however. The first is generalized Schur decomposition of complex pencils. This PR adds complex support (zgges/cgges) to GeneralizedSchurWs and LAPACK.gges!(ws, ...). (The second functionality we need in Quantica will come in a subsequent PR).

The main thing to focus on is that GeneralizedSchurWs{T, RT} has now two parameters (in line with other complex workspaces in the package like GeneralizedEigenWs{T, MT, RT}). T is the eltype (that can now be complex), and RT is always real(T).

I've used Claude Code to help me, but I've thoroughly reviewed any change it proposed.

Changes

  • The gges loop now runs over (gges, elty, relty) for all four element types, following ggev in eigen.jl. A cmplx branch selects the complex ccall. The real code path is unchanged apart from indentation.
  • For complex matrices, αr in GeneralizedSchurWs{T,RT} holds α and αi::Vector{RT} serves as the real rwork (length 8n), as in GeneralizedEigenWs. GeneralizedSchurWs{Float64} remains valid in annotations and dispatch of course. The only visible change for real matrices is the printed type, so the doctest was updated.
  • select is not supported for complex matrices yet (the callback signature differs), and passing it throws an ArgumentError if the matrices are complex.
  • For complex matrices, gges! returns (A, B, ws.αr, ws.β, ws.vsl, ws.vsr) and allocates nothing after warm-up.

Tests

A "Complex, square" testset in GeneralizedSchurWs (ComplexF64 and ComplexF32) compares the results against LAPACK.gges!. It also covers the Workspace/factorize! path, the select error, and resizing / WorkspaceSizeError. The full suite passes locally on Julia 1.10 and 1.13.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant