Skip to content

Fix SGEBAL test failure - #1338

Merged
langou merged 1 commit into
Reference-LAPACK:masterfrom
ACSimon33:fix-chkbl-missing-abs
Jul 28, 2026
Merged

langou merged 1 commit into
Reference-LAPACK:masterfrom
ACSimon33:fix-chkbl-missing-abs

Conversation

@ACSimon33

Copy link
Copy Markdown
Collaborator

Summary

SCHKBL/DCHKBL measure the relative error between the balanced matrix and the stored
reference with

TEMP = MAX( A( I, J ), AIN( I, J ) )
TEMP = MAX( TEMP, SFMIN )
VMAX = MAX( VMAX, ABS( A( I, J )-AIN( I, J ) ) / TEMP )

The denominator is missing ABS. For an entry where both A(I,J) and AIN(I,J) are
negative, MAX returns a negative value, the clamp on the next line replaces it with
SFMIN, and the (non-negative) numerator is then divided by the smallest normalized
number.

In single precision, that overflows. xeigtsts < sbal.in on master reports:

 .. test output of SGEBAL ..
 value of largest test error            =     Infinity
 example number where info is not zero  =    0
 example number where ILO or IHI wrong  =    0
 example number having largest error    =   11
 number of examples where info is not 0 =    0
 total number of examples tested        =   13

Warning: Floating overflow occurred

The complex checkers already get this right — CCHKBL/ZCHKBL apply CABS1 to both
arguments of the MAX (TESTING/EIG/cchkbl.f:142).

Fix

Take absolute values before the MAX, matching the complex checkers:

TEMP = MAX( ABS( A( I, J ) ), ABS( AIN( I, J ) ) )

Applied to TESTING/EIG/schkbl.f and TESTING/EIG/dchkbl.f.

Effect

test before after
SGEBAL (sbal.in) Infinity at example 11, floating overflow 0.100E+01 at example 5
DGEBAL (dbal.in) 0.100D+01 at example 5 0.100D+01 at example 5 (unchanged)
CGEBAL (cbal.in) 0.100E+01 at example 5 untouched
ZGEBAL (zbal.in) 0.100D+01 at example 5 untouched

All four precisions now report the same finite largest error at the same example.

DCHKBL's reported value does not change on the current data — in double precision the
entries hitting the negative-denominator path happen to be exactly equal, so the numerator
is zero and 0/SFMIN is harmless. The metric was equally wrong there, though, and would
misreport for any input where those entries differ, so it is fixed alongside the single
precision one.

Notes

  • The SCALE comparison loop just below uses MAX( SCALE( I ), SCALIN( I ) ) with no
    ABS. Left as is deliberately: ?GEBAL returns scaling factors that are positive powers
    of the radix, so ABS would be a no-op. The complex checkers do the same.
  • Test-only change. Nothing under SRC/ or BLAS/ is touched, so no library behavior
    changes — this only fixes the error metric used to report ?GEBAL accuracy.

The relative-error denominator used MAX(A(I,J), AIN(I,J)) without
taking absolute values. For entries where both matrices are negative,
the subsequent clamp replaced the denominator with SFMIN, and the
difference divided by SFMIN overflowed to Infinity in single precision
(sbal.in example 11). The complex checkers already use CABS1 here.

sbal now reports the same finite largest error (0.100E+01, example 5)
as the other three precisions.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 28, 2026 14:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@langou
langou merged commit 6737170 into Reference-LAPACK:master Jul 28, 2026
15 checks passed
@langou

langou commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Oh my. That was the error!!!!!! 🤦 Well, thanks a lot. Good to fix this.

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.

3 participants