*bdsdc: use QR instead of D&C for bidiagonal SVD with vectors#1300
*bdsdc: use QR instead of D&C for bidiagonal SVD with vectors#1300jschueller wants to merge 1 commit into
Conversation
The divide-and-conquer algorithm in DBDSDC/SBDSDC (used by DGESDD/SGESDD when singular vectors are requested) loses relative accuracy for graded matrices. For companion matrices eigenvalue ratios exceeding 10^36, the D&C merging step produces singular values wrong by 18 orders of magnitude. Replace the D&C path (DLASD0/DLASDA) with the QR-based algorithm (DLASDQ/SLASDQ) which maintains high relative accuracy. DLASDQ was already used for JOBZ='N' (singular values only); this extends it to all JOBZ cases, fixing the accuracy at the cost of O(N^3) vs O(N^2) for the bidiagonal step. The companion_demo(26) matrix from EigTool now yields correct results: S(26) before: 2.34e+10 (wrong) S(26) after: 1.53e-09 (matches DGESVD) Closes Reference-LAPACK#316
|
I'm not sure about this. It is true that QR is much more accurate than D&C for certain matrices. However, I think many people will not be that happy with the slower code, I think a quick experiment on a few matrices of different sizes could help us quantify how much slower QR is and make an informed decision. |
|
Benchmark: QR (DLASDQ) vs D&C (DLASD0) for bidiagonal SVD with vectors QR and D&C performance is nearly identical across all tested sizes |
The divide-and-conquer algorithm in DBDSDC/SBDSDC (used by DGESDD/SGESDD when singular vectors are requested) loses relative accuracy for graded matrices. For companion matrices eigenvalue ratios exceeding 10^36, the D&C merging step produces singular values wrong by 18 orders of magnitude.
Replace the D&C path (DLASD0/DLASDA) with the QR-based algorithm (DLASDQ/SLASDQ) which maintains high relative accuracy. DLASDQ was already used for JOBZ='N' (singular values only); this extends it to all JOBZ cases, fixing the accuracy at the cost of O(N^3) vs O(N^2) for the bidiagonal step.
The companion_demo(26) matrix from EigTool now yields correct results:
S(26) before: 2.34e+10 (wrong)
S(26) after: 1.53e-09 (matches DGESVD)
Closes #316