-
Notifications
You must be signed in to change notification settings - Fork 495
Description
Summary
This change replaces duplicated local ABSSQ statement-function definitions in
the complex Givens rotation related routines with shared external BLAS helpers:
CABSSQforCOMPLEXZABSSQforDOUBLE COMPLEX
The following callers are updated:
BLAS/SRC/crotg.f90BLAS/SRC/zrotg.f90SRC/clartg.f90SRC/zlartg.f90SRC/clargv.fSRC/zlargv.f
Motivation
Several BLAS/LAPACK routines currently carry identical local ABSSQ
statement-function definitions of the form:
REAL(x)**2 + AIMAG(x)**2DBLE(x)**2 + DIMAG(x)**2
Centralizing this tiny helper reduces duplication, simplifies maintenance, and
also reduces reliance on local statement functions in the conversion pipeline.
Numerical behavior
This change is intended to preserve the original numerical behavior.
The helper formula is kept exactly in the same form as before:
CABSSQ(t) = REAL(t)**2 + AIMAG(t)**2ZABSSQ(t) = DBLE(t)**2 + DIMAG(t)**2
In particular:
- this patch does not replace the helper with
ABS(t)**2 - this patch does not move Blue-scaling logic into the helper
- this patch does not change Blue constants, scaling thresholds, or branch structure
All Blue-scaling and safe-scaling logic remains local to the existing callers.
Notes
This is a refactoring change only.
If later review shows that loop-local statement functions are preferred over
external helpers for performance reasons, the same cleanup can be reworked into
an include-based statement-function form without changing the caller-side logic.
proposed implimentations
REAL FUNCTION CABSSQ(T)
*
* -- Shared helper for complex squared magnitude ------------------------
* Returns REAL(T)**2 + AIMAG(T)**2.
* This intentionally does not use ABS(T)**2 and does not perform any
* scaling. Blue-scaling remains the responsibility of the caller.
*
COMPLEX T
CABSSQ = REAL(T)**2 + AIMAG(T)**2
RETURN
END
DOUBLE PRECISION FUNCTION ZABSSQ(T)
*
* -- Shared helper for double complex squared magnitude -----------------
* Returns DBLE(T)**2 + DIMAG(T)**2.
* This intentionally does not use ABS(T)**2 and does not perform any
* scaling. Blue-scaling remains the responsibility of the caller.
*
DOUBLE COMPLEX T
ZABSSQ = DBLE(T)**2 + DIMAG(T)**2
RETURN
END
Before opening a PR, I would like to ask whether this approach looks acceptable.
If there are no objections to introducing shared CABSSQ / ZABSSQ helpers for this cleanup, I will prepare a pull request.