From 271bf8f3dc7de24dc98601e6c38239a57f456b64 Mon Sep 17 00:00:00 2001 From: Kyungmin Lee Date: Sun, 3 May 2026 22:47:50 -0700 Subject: [PATCH] fix post-loop SIDE/TRANS guard in p?ormrz / p?unmrz In PCUNMRZ/PDORMRZ/PSORMRZ/PZUNMRZ, the post-loop guard that controls the leading-partial-block PORMR3/PUNMR3 fix-up was a byte-for-byte copy of the pre-loop guard. The same condition gated both blocks, so the post-loop fired together with the pre-loop in the (LEFT,!NOTRAN) / (RIGHT,NOTRAN) directions (over-applying K-1 reflectors to an already transformed C) and never fired in the complementary (LEFT,NOTRAN) / (RIGHT,!NOTRAN) directions (silently skipping the leading partial block of reflectors). All four SIDE/TRANS combinations produced numerically incorrect results. Replace the post-loop guard with the complement of the pre-loop guard, matching the analogous structure in p?ormrq.f. --- SRC/pcunmrz.f | 4 ++-- SRC/pdormrz.f | 4 ++-- SRC/psormrz.f | 4 ++-- SRC/pzunmrz.f | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/SRC/pcunmrz.f b/SRC/pcunmrz.f index e5ccc3d2..a162162e 100644 --- a/SRC/pcunmrz.f +++ b/SRC/pcunmrz.f @@ -455,8 +455,8 @@ SUBROUTINE PCUNMRZ( SIDE, TRANS, M, N, K, L, A, IA, JA, DESCA, $ WORK( IPW ) ) 10 CONTINUE * - IF( ( LEFT .AND. .NOT.NOTRAN ) .OR. - $ ( .NOT.LEFT .AND. NOTRAN ) ) THEN + IF( ( LEFT .AND. NOTRAN ) .OR. + $ ( .NOT.LEFT .AND. .NOT.NOTRAN ) ) THEN IB = I2 - IA IF( LEFT ) THEN MI = M diff --git a/SRC/pdormrz.f b/SRC/pdormrz.f index f2d48dc2..946aa341 100644 --- a/SRC/pdormrz.f +++ b/SRC/pdormrz.f @@ -455,8 +455,8 @@ SUBROUTINE PDORMRZ( SIDE, TRANS, M, N, K, L, A, IA, JA, DESCA, $ WORK( IPW ) ) 10 CONTINUE * - IF( ( LEFT .AND. .NOT.NOTRAN ) .OR. - $ ( .NOT.LEFT .AND. NOTRAN ) ) THEN + IF( ( LEFT .AND. NOTRAN ) .OR. + $ ( .NOT.LEFT .AND. .NOT.NOTRAN ) ) THEN IB = I2 - IA IF( LEFT ) THEN MI = M diff --git a/SRC/psormrz.f b/SRC/psormrz.f index 0947b594..82a21ea9 100644 --- a/SRC/psormrz.f +++ b/SRC/psormrz.f @@ -455,8 +455,8 @@ SUBROUTINE PSORMRZ( SIDE, TRANS, M, N, K, L, A, IA, JA, DESCA, $ WORK( IPW ) ) 10 CONTINUE * - IF( ( LEFT .AND. .NOT.NOTRAN ) .OR. - $ ( .NOT.LEFT .AND. NOTRAN ) ) THEN + IF( ( LEFT .AND. NOTRAN ) .OR. + $ ( .NOT.LEFT .AND. .NOT.NOTRAN ) ) THEN IB = I2 - IA IF( LEFT ) THEN MI = M diff --git a/SRC/pzunmrz.f b/SRC/pzunmrz.f index d5d95d5e..27916970 100644 --- a/SRC/pzunmrz.f +++ b/SRC/pzunmrz.f @@ -456,8 +456,8 @@ SUBROUTINE PZUNMRZ( SIDE, TRANS, M, N, K, L, A, IA, JA, DESCA, $ WORK( IPW ) ) 10 CONTINUE * - IF( ( LEFT .AND. .NOT.NOTRAN ) .OR. - $ ( .NOT.LEFT .AND. NOTRAN ) ) THEN + IF( ( LEFT .AND. NOTRAN ) .OR. + $ ( .NOT.LEFT .AND. .NOT.NOTRAN ) ) THEN IB = I2 - IA IF( LEFT ) THEN MI = M