Skip to content

TESTING/MATGEN: guard zero leading element in CLAGHE - #1366

Merged
langou merged 1 commit into
Reference-LAPACK:masterfrom
nakatamaho:fix-claghe-zero-leading
Aug 24, 2026
Merged

langou merged 1 commit into
Reference-LAPACK:masterfrom
nakatamaho:fix-claghe-zero-leading

Conversation

@nakatamaho

Copy link
Copy Markdown
Contributor

Summary

This is a follow-up to #1365 for the complex-single counterpart, CLAGHE.

CLAGHE computes the phase of a Householder reflector using expressions of the form

WA = ( WN / ABS( WORK( 1 ) ) )*WORK( 1 )

When WN is nonzero but the leading element is exactly zero, the expression evaluates as Inf * 0 and can produce NaNs. This is possible at higher precision when rounding makes the leading element zero while the remaining vector still has a nonzero norm. The same expression occurs in both reflector-generation loops in CLAGHE.

The patch:

  • sets WA = ZERO and TAU = ZERO for a zero norm;
  • selects the finite positive-real phase WA = CMPLX(WN, 0.0E+0) for a nonzero norm with a zero leading element;
  • preserves the existing phase computation otherwise.

The positive-real phase is valid for a zero leading element and yields a finite reflector with TAU = 1.

Validation

  • gfortran -ffixed-form -ffixed-line-length-72 -fsyntax-only TESTING/MATGEN/claghe.f

CLAGHE formed the phase of a Householder reflector as (WN / ABS(WORK(1))) * WORK(1), and used the analogous expression in the band-reduction loop. If WN is nonzero while the leading element rounds to zero, this evaluates as Inf * 0 and contaminates the generated Hermitian matrix with NaNs.

Use a finite positive-real phase when the leading element is zero, while preserving the zero-norm and ordinary phase paths. This is the complex-single counterpart of PR Reference-LAPACK#1365's ZLAGHE fix.
@langou
langou merged commit 397be5a into Reference-LAPACK:master Aug 24, 2026
43 of 44 checks passed
ilayn added a commit to ilayn/semicolon-lapack that referenced this pull request Oct 26, 2026
…ects (#43)

- Use the DLAMCH constant the Fortran asks for in 35 routines (and their
  s/c copies). DBL_EPSILON stood in for DLAMCH('Epsilon'), which is half
  of it, or the reverse. In xLAGTS this doubled the pivot tolerance, and
  inverse iteration in xSTEIN failed on tight clusters, so ZHEEVX/ZHPEVX
  returned INFO > 0 where reference LAPACK succeeds.
- xGEDMD returns after XERBLA in the NaN checks of X and Y.
  Reference-LAPACK/lapack#1395
- ZLAGHE/CLAGHE guard a zero leading element of the reflector.
  Reference-LAPACK/lapack#1365
  Reference-LAPACK/lapack#1366
- xTSQR01 checks the GEMLQ('R','N') residual it computes.
  Reference-LAPACK/lapack#1364
- xDRVES: Fortran xSLECT with SELOPT = 0, complete test 13, and the
  documented xGEES exit codes N+1 and N+2.
  Reference-LAPACK/lapack#1355
- IL/IU drawn from the full [1, N] range in the CHKST, DRVST, DRVSG,
  CHKBD and DRVBD drivers, and the xDRVBD GESVDX tests ported line by
  line.
  Reference-LAPACK/lapack#1347
- xDRVLS random right-hand sides and EPS, real QZ drivers SAFMIN/ULP, RFP
  driver parameters from the *test_rfp.in files, invented singular values
  removed from the xDRVBD generator, new seed for zDRVST/zDRVST2STG.
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.

2 participants