Add specialized svd(::SymTridiagonal{<:Real}) #1833
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 323 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.346
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1833"
general
weight: 0.35
stevengj
Add specialized
svd(::SymTridiagonal{<:Real})Follow-up to #1827, which added
svdvals(::SymTridiagonal{<:Real})). @stevengj flagged this in review as the natural next step.Stacked on #1827, the diff below will show that PR's commits (06aebbf, 560a4f4, 58cb46a) until it merges.
Motivation
svd(A::SymTridiagonal)currently falls through to the genericsvd(::AbstractMatrix), which goes througheigencopy_oftype-> densegesdd!. Same root cause #1827 fixed forsvdvals: the tridiagonal structure is thrown away.Fix
Empty input is handled by returning an SVD with eigtype-typed fields before calling eigen! (eigen on n=0 throws inside stegr!).
svddelegates tosvd!viacopymutable_oftype, so the guard lives in one place.Signature
Matches the sibling
svdvals(::SymTridiagonal{<:Real}). Complex falls through to the generic dense path; verified thatSymTridiagonal{ComplexF64}constructs andsvdreturns the correct factorization viagesdd!. Float16 promotes to Float32 for the eigendecomposition, same as the dense path.full,alg,atol,rtolare accepted for API compatibility withsvd(::AbstractMatrix)but are no-ops for square input.Tests
In
test/tridiag.jl, new testsetsvd(::SymTridiag):F.U Diagonal(F.S) F.Vt ≈ AF.U' F.U ≈ I,F.Vt F.Vt' ≈ Iissorted(F.S; rev=true)svdvals(A)sign(0)trap)eigen, which throws onn=0)Inteigtypeand@inferredfullkwarg no-oprank(::SVD)on the resultBenchmarks
svd(SymTridiagonal(randn(n), randn(n-1)))vssvd(Matrix(SymTridiagonal(...))), Julia 1.13.3, x86_64,@elapsedmin-of-5-after-warmup:| n | dense (ms) | this PR (ms) | speedup |
|-----:|-----------:|-------------:|--------:|
| 256 | 12.0 | 7.7 | 1.6x |
| 1024 | 322.0 | 124.4 | 2.6x |
| 2048 | 4526.0 | 495.2 | 9.1x |
Smaller ratios than #1827's
svdvalstable becausestegr!with eigenvectors has a much larger constant than eigenvalues-only, and reconstruction adds another O(n^2). Asymptotics are still O(n^2) vs O(n^3), and the ratio grows with n.svd!avoids thecopy(dv)/copy(ev)insideeigen, saving O(n) against the O(n^2) reconstruction. 26% faster at n=256, noise at n=1024, within noise at n=2048. Included for parity withsvdvals!; happy to drop if smaller surface area is preferred.