Skip to content

Add syevd! for HermitianEigenWs - #55

Open
blegat wants to merge 1 commit into
DynareJulia:mainfrom
blegat:bl/syevd
Open

blegat wants to merge 1 commit into
DynareJulia:mainfrom
blegat:bl/syevd

Conversation

@blegat

@blegat blegat commented Nov 5, 2026

Copy link
Copy Markdown

Needed in blegat/LowRankOpt.jl#107. It seems to fit quite well within this package so I'm contributing it here instead of adding it in LowRankOpt, let me know if the contribution makes sense.

The divide-and-conquer algorithm of `syevd` is faster than the MRRR
algorithm of `syevr` to compute all the eigenvectors, especially when the
eigenvalues are clustered, e.g., in the scaling of interior-point methods for
semidefinite programs near the central path.

Eigenvalues and eigenvectors of a symmetric `801 × 801` matrix with the
eigenvalues `1 + δ * randn()` and 10 BLAS threads:

| Spectrum | syevr | syevd |
|---|---|---|
| exp10.(range(-8, 2)) | 42.2 ms | 32.1 ms |
| δ = 1e-1 | 75.4 ms | 35.9 ms |
| δ = 1e-3 | 72.7 ms | 34.4 ms |
| δ = 1e-6 | 75.3 ms | 34.1 ms |
blegat added a commit to blegat/LowRankOpt.jl that referenced this pull request Nov 9, 2026
* Use syevd for the eigenvectors of EigenWorkspace

The divide-and-conquer algorithm of `syevd` is about twice as fast as the
MRRR algorithm of `syevr` to compute all eigenvectors when the eigenvalues
are clustered, as for the NT scaling of Loraine near the central path, where
`X Z ≈ μ I`. `LAPACK.syevd!` allocates its work arrays until
FastLapackInterface supports `syevd!` with a preallocated workspace.

Eigenvalues and eigenvectors of a symmetric `801 × 801` matrix with the
eigenvalues `1 + δ * randn()` and 10 BLAS threads:

| Spectrum | syevr | syevd |
|---|---|---|
| exp10.(range(-8, 2)) | 42.2 ms | 32.1 ms |
| δ = 1e-1 | 75.4 ms | 35.9 ms |
| δ = 1e-3 | 72.7 ms | 34.4 ms |
| δ = 1e-6 | 75.3 ms | 34.1 ms |

Total time with Loraine (kit=0 unless specified):

| Problem | syevr | syevd |
|---|---|---|
| theta1 | 0.33 s | 0.33 s |
| control1 | 0.32 s | 0.32 s |
| tru9 | 9.1 s | 8.9 s |
| vib9 | 29.6 s | 29.4 s |
| vib9, kit=1 | 2.1 s | 2.0 s |
| maxG11 | 5.5 s | 5.1 s |
| thetaG11 | 7.1 s | 5.7 s |
| thetaG51 (first 4 iterations) | 7.3 s | 7.1 s |

* Allocation-free syevd until FastLapackInterface supports it

`LinearAlgebra.LAPACK.syevd!` allocates its eigenvalues and work arrays,
which made the iterations of Loraine allocate 1280 B. Call `dsyevd` and
`ssyevd` directly with work arrays stored in `EigenWorkspace`, resized by
the first call. The branch `bl/fli_syevd` replaces this with
`FastLapackInterface.syevd!` from
DynareJulia/FastLapackInterface.jl#55 once it is
released.
blegat added a commit to blegat/LowRankOpt.jl that referenced this pull request Nov 9, 2026
Replace the direct calls to `dsyevd` and `ssyevd` by `syevd!` of
FastLapackInterface, added by
DynareJulia/FastLapackInterface.jl#55. The compat
assumes that it is released as 2.2; adjust it to the version that contains
it before merging.
@blegat

blegat commented Nov 19, 2026 •

Copy link
Copy Markdown
Author

@MichelJuillard @svillemot kind reminder :)

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