Commit Graph
3539 Commits
Author SHA1 Message Date
meng004 3a30b715ff Fix LAPACKE_?lacpy_work row-major triangular copy (#729)
The row-major branch transposed the full m-by-n matrix through
temporaries and copied the never-written complementary region of the
destination temporary back over B, corrupting the triangle uplo requires
to be preserved and reading uninitialized memory. Call the Fortran kernel
directly with uplo swapped (U<->L) and m/n swapped, exactly as the
correct column-major path does. Applies identically to s/d/c/z.
2026-07-06 15:03:58 +00:00
langou 98e5d7a237 Merge pull request #1315 from sameer-amd-in/issue1314
{s/c/d/z}larf{/1f/1l}: fix negative increment vector handling
2026-06-24 02:20:05 -06:00
samahmad 77abd25204 {s/c/d/z}larf{/1f/1l}: fix negative increment vector handling
Handle negative increment values in vector offsetting.

Change-Id: I2a0993e1ec22f8029d49d30d18be0152db480ded
2026-06-23 22:06:06 -07:00
langou 122f8924ed Merge pull request #1309 from amilsted/issue_995 2026-06-15 12:23:09 -06:00
Ashley Milsted b7966d4acd Scale FAIL with SPDIAM in xLARRF. Fixes #995. 2026-06-15 10:38:52 -07:00
langou 0f819939d2 Merge pull request #1307 from jschueller/issue326
DLASQ3, SLASQ3: stop modifying QMAX
2026-06-15 05:47:52 -06:00
Julien Schueller 3e177d2306 DLASQ3, SLASQ3: document QMAX as in/out
Closes #326
2026-06-15 13:37:49 +02:00
langou 966a012664 Merge pull request #1296 from jschueller/arm
CI: Enable ubuntu/arm
2026-06-15 01:13:15 -06:00
Julien Schueller ad435c2ad3 CI: Enable ubuntu-24.04-arm 2026-06-13 12:23:25 +02:00
langou fbd4146ce5 Merge pull request #1286 from jschueller/issue255
dlasd2/slasd2: Increase deflation tolerance to match dlasd7/slasd7
2026-06-13 04:02:37 -06:00
langou 1b2cbb7649 Merge pull request #1293 from jschueller/issue965
dbbcsd/sbbcsd/cbbcsd/zbbcsd: fix insufficiently accurate U2 in CS dec…
2026-06-13 03:58:48 -06:00
langou 048d12f150 Merge pull request #1292 from jschueller/issue546
ormqr/ormlq/ormrq/ormql, unmqr/unmlq/unmrq/unmql: fix minimum workspa…
2026-06-13 03:57:23 -06:00
langou 21af89cef0 Merge pull request #1287 from jschueller/issue734
LAPACKE/tprfb_work: fix row-major A dimensions for SIDE='R'
2026-06-13 03:55:39 -06:00
langou e938bbbe24 Merge pull request #1285 from jschueller/issue242
bdsqr: Fix INFO return when NCVT=NRU=NCC=0
2026-06-13 03:54:01 -06:00
langou f5340708e6 Merge pull request #1294 from changangela/fix-lapacke-nancheck-overflow
Fix integer overflow in LAPACKE nancheck helpers for large matrices
2026-06-12 01:55:18 -06:00
langou 192037884c Merge pull request #1261 from ACSimon33/fix_warnings
Fix Intel Classic build on Windows and various warnings
2026-06-12 01:42:07 -06:00
langou 078d8978db Merge pull request #1280 from ACSimon33/cherry-pick-7872e2d6
Fixed CBLAS symbol name: cblas_zaxbpy_64 -> cblas_zaxpby_64
2026-06-12 01:38:54 -06:00
langou fd8e6db995 Merge pull request #1289 from jschueller/issue676
gelsy: fix ILAENV workspace query routines for TZRZF/UNMRZ
2026-06-12 01:37:02 -06:00
langou d5dbabe3f5 Merge pull request #1291 from jschueller/issue549
dorcsd2by1/uncsd2by1: avoid OOB access with zero rows
2026-06-12 01:34:55 -06:00
Yue Chang 23b489104f Fix integer overflow in LAPACKE nancheck helpers for large matrices
Offset computations like j*lda overflow 32-bit lapack_int once
n = lda >= 46341, e.g. LAPACKE_dpotrf crashes in its NaN check before
the factorization runs. Cast to size_t (or int64_t for the tz offsets)
the same way ge/gb/tp/tf already do.
2026-06-12 01:41:44 -04:00
Julien Schueller a73f4a6524 dbbcsd/sbbcsd/cbbcsd/zbbcsd: fix insufficiently accurate U2 in CS decomposition
The Golub-Reinsch-SVD-style iteration in xBBCSD used an absolute
convergence threshold THRESH ~ 90*EPS to decide when off-diagonal
bulges are negligible and can be skipped.  For rows where the
diagonal entries are small (tiny singular values in the ratio),
this absolute threshold is too large relative to the diagonal,
causing the algorithm to stop chasing bulges prematurely and
producing inaccurate singular vectors (||X21 - U2 D2 V^*|| up to
50*EPS ||X21||).

Fix: change all bulge-convergence checks (RESTART flags in the
inner loop, initial bulge-chase decisions, and the IMAX-1 cleanup)
from absolute to relative by scaling THRESH by the adjacent diagonal
entries:

  RESTART11 = |B11E|^2+|BULGE|^2 <= (THRESH * MAX(|B11D(I-1)|,|B11D(I)|,UNFL))^2

This mirrors DBDSQR's relative convergence check |E| <= TOL*|D|.
Applied to all 4 bidiagonal blocks (B11/B21/B12/B22) at all 3
check-points in the iteration.

Fixes #965
2026-06-11 19:15:11 +02:00
Julien Schueller 05628e3e0d ormqr/ormlq/ormrq/ormql, unmqr/unmlq/unmrq/unmql: fix minimum workspace for tiny M,N,K
The workspace query formula LWKOPT = NW*NB + TSIZE used TSIZE = LDT*NBMAX
= 65*64 = 4160, a hardcoded constant.  The blocked algorithm only stores
one T matrix block at a time (reused across loop iterations), so the
per-iteration workspace is LDT*NB, not LDT*NBMAX.  For tiny M,N,K where
a single block suffices (NB >= N or NB >= K), LWKOPT was always >= 4160
regardless of problem size.

Fix: change LWKOPT = NW*NB + TSIZE  ->  LWKOPT = NW*NB + LDT*NB.

The NB adjustment formula when LWORK is limited must consistently use
the per-iteration T storage instead of TSIZE:

  NB = (LWORK - TSIZE) / LDWORK  ->  NB = LWORK / (LDWORK + LDT)

Applied to all 16 routines (s,d,c,z x {orm,unm}{qr,rq,lq,ql}).

Closes #546
2026-06-11 17:06:32 +02:00
Julien Schueller 6649f3999f dorcsd2by1/uncsd2by1: avoid OOB access with zero rows
When P=0 and M=Q (U2 is M-by-M, X21 is M-by-M and orthogonal),
or P=M and M=Q (U1 is M-by-M, X11 is M-by-M and orthogonal),
or Q=0, the minimal dimension R = MIN(P, M-P, Q, M-Q) is zero,
so C and S are empty.  In these degenerate cases the preceding
code entered the R == P or R == M-P branch and called the
bidiagonalization subroutines (SORBDB2/SORBDB3) which then
accessed elements X21(I,I+1) or X11(I,I+1) out of bounds in
the second DO loop (I = P+1, Q or I = M-P+1, Q).

Fix: handle R = 0 directly in the four driver routines before
the case-dependent bidiagonalization path.  The three trivial
CSD cases are:

  Q = 0:     set U1 = I, U2 = I, return.
  P = 0, M = Q:  copy X21 to U2, set V1T = I, return.
  P = M, M = Q:  copy X11 to U1, set V1T = I, return.

All other R=0 configurations are non-standard and still fall
through to the existing path (which may fail).

Fixes #549
2026-06-11 16:58:16 +02:00
Julien Schueller ed7d20cd23 gelsy: fix ILAENV workspace query routines for TZRZF/UNMRZ
The workspace NB queries in all four ?gelsy variants used
?GERQF and ?UNMRQ, but the routines actually called at runtime
are ?TZRZF and ?UNMRZ (real) / ?UNMRZ (complex).

While ?GERQF and ?TZRZF are related (both produce an RQ-like
factorization), their block sizes may differ in ILAENV's tuned
values.  If the user relied on LWKOPT from the query to allocate
exactly the right workspace, the actual ?TZRZF/?UNMRZ calls could
underflow or overflow the work array.

Fix the ILAENV calls to match the routines actually invoked:
  ?GERQF -> ?TZRZF
  ?UNMRQ -> ?UNMRZ

Closes #676
2026-06-11 16:26:07 +02:00
langou 077667a1be Merge pull request #1284 from jschueller/cblas
Misc fixes
2026-06-11 08:14:19 -06:00
Julien Schueller fd020b441b LAPACKE/tprfb_work: fix row-major A dimensions for SIDE='R'
The row-major path hardcoded `lda_t = MAX(1,k)`, which is only correct
when SIDE='L' (A is K-by-N). When SIDE='R', A is M-by-K and the
transposition dimensions, allocation, and leading-dimension checks were
all wrong.

- Introduce nrowsA/ncolsA/nrowsV determined by SIDE (following the
  same pattern as the LAPACKE_?tpmqrt_work fix in PR #540).
- lda_t now uses nrowsA instead of always k.
- lda check compares against ncolsA instead of always m.
- A transpose uses (nrowsA, ncolsA) instead of (k, m).
- LDV check depends on STOREV: ldv >= nrowsV for STOREV='C',
  ldv >= k for STOREV='R'.
- V transpose uses nrowsV rows instead of ldv.

Closes #734
2026-06-11 16:08:45 +02:00
Julien Schueller 0e0f23592e dlasd2/slasd2: Increase deflation tolerance to match dlasd7/slasd7
Fix DBDSDC/SBDSDC returning non-orthogonal U/V for bidiagonal matrices
with many nearly-equal singular values (e.g., all singular values ≈ 1).

The divide-and-conquer bidiagonal SVD has two code paths:
- Full vector path (DLASD2/SLASD2): deflation tolerance = 8 * EPS
- Compact path  (DLASD7/SLASD7): deflation tolerance = 64 * EPS

With the weaker tolerance (8*EPS), singular values differing by only
~10*EPS (e.g., ~2e-15 for double precision) escape deflation.  The
subsequent Z computation in DLASD3 then suffers catastrophic
cancellation from denominators (σ_i - σ_j) that are tiny, polluting the
singular vectors and causing loss of orthogonality.

Raise DLASD2 and SLASD2 to 64*EPS, matching DLASD7 and SLASD7, so more
close singular values are deflated and the singular-vector computation
remains stable.

Closes #255
2026-06-11 15:56:56 +02:00
langou 92ef3aaeb8 Merge pull request #1259 from ACSimon33/fix_python_test_summary
Fix Python test summary
2026-06-11 07:47:29 -06:00
Julien Schueller 3ecbd1d097 bdsqr: Fix INFO return when NCVT=NRU=NCC=0
Problem: When NCVT = NRU = NCC = 0 (no singular vectors requested),
BDSQR calls the dqds algorithm. If dqds failed with INFO = 1 or 3,
the routine returned immediately with that error, even though the
standard QR algorithm could still compute the singular values. Only
INFO = 2 triggered the fallback.

Change `IF( INFO .NE. 2 ) RETURN` to `IF( INFO .EQ. 0 ) RETURN`
after the dqds call, so the standard QR fallback runs on any
dqds failure (INFO=1,2,3) and not only INFO=2.

Closes #242
2026-06-11 15:33:25 +02:00
langou 6e88a11703 Merge pull request #1251 from martin-frbg/issue1183
Optimize looping over the lower triangular in fat matrix cases of LACPY/LANTR/LASCL
2026-06-11 07:16:58 -06:00
Julien Schueller 283cf5b76d Make LAPACKE_[cz]tgexc pass ifst/ilst as pointer outputs
Per LAPACK docs, in [cz]tgexc, ilst is [in,out]. The LAPACKE C
interface was passing both ifst and ilst by value as input-only
scalars, so callers could never observe the updated ilst value.

Change both ifst and ilst to lapack_int* pointers in the complex
tgexc variants to match the real-precision stgexc/dtgexc interface
and the underlying Fortran semantics.

Fixes #771
2026-06-11 15:05:22 +02:00
Julien Schueller 91c0f61b87 Guard ?GEEV/?GEEVX undo-scaling against negative INFO
When ?HSEQR encounters non-finite input, it can return a negative
INFO. The undo-scaling block at label 50 then computes N-INFO (which
exceeds N) and indexes WR( INFO+1 ) (out of bounds), causing memory
corruption through ?LASCL.

Add INFO.GE.0 to the outer IF( SCALEA ) guard so the undo-scaling
block is skipped entirely when INFO is negative. The inner
IF( INFO.GT.0 ) guard only covered the second pair of ?LASCL calls.

Fixes #1128
2026-06-11 15:05:19 +02:00
Julien Schueller 6dc1a78eae Fix DROTMG/SROTMG rescaling overwriting DH12
When DFLAG=0 and both DD1 and DD2 need rescaling, the first
scaling loop transitions DFLAG from 0 to -1 and correctly
scales DH11 and DH12. But the second scaling loop then hits
the ELSE branch (matching DFLAG=-1) which unconditionally
resets DH21=-1 and DH12=1, overwriting the scaled DH12.

Change ELSE to ELSE IF (DFLAG.EQ.ONE) so the implied-element
initialization (DH21=-1, DH12=1) only fires when DFLAG=1,
not when DFLAG=-1 (where all elements are already explicit).

Fixes #244
2026-06-11 15:05:19 +02:00
Julien Schueller 526a4fbbd3 Fix mislabeled comments in dget38.f
Two comments in the DGEHRD/DHSEQR test incorrectly say "Compute
Schur form":
- The DGEHRD call reduces to upper Hessenberg form, not Schur.
- The DHSEQR call computes eigenvalues and the Schur form, so
  use a more descriptive label.

Fixes #587
2026-06-11 15:05:19 +02:00
Julien Schueller 3d668fe93f LAPACKE: Make LDU/LDVT checks in GESVD conditional on JOBU/JOBVT
When JOBU='N' or JOBVT='N', the U and VT matrices are not referenced,
so the leading dimension checks should be skipped.  Previously the
code rejected ldvt=0 (and ldu=0) even when those matrices were not
used, causing a spurious INFO=12 error on row-major calls with
JOBVT='N' (or INFO=10 for JOBU='N').

Fixes #1090
2026-06-11 14:39:38 +02:00
Julien Schueller fd16118505 cblas_ctrmm: fix error check
Closes #1188
2026-06-11 14:39:38 +02:00
Julien Schueller 7a721b3fac lapacke: fix memory allocation on error 2026-06-11 14:39:38 +02:00
Julien Schueller d296703051 lapacke_zgedmdq: fix routine name 2026-06-11 14:39:38 +02:00
Julien Schueller 8a43b6869a cblas_zgemmtr: Fix routine name 2026-06-11 14:39:38 +02:00
Julien Schueller ea7f51048f cblas_dgemmtr: Fix syntax error 2026-06-11 14:39:38 +02:00
langou 54b6620d27 Merge pull request #1264 from AymenQ/fix-complex-nrm2-inf-test
Fix complex NRM2 tests for matching infinite results
2026-06-11 04:15:19 -06:00
langou a66e2a37c4 Merge pull request #1252 from scr2016/refactor-github-workflow-file-cmake_yml--config
in .github/workflows/cmake.yml, removed redundant '--config ${{env.BUILD_TYPE}}' from 'cmake --build build'
2026-06-01 00:25:52 -06:00
langou 7e4e6bf07e Merge pull request #1039 from haox1/stebz
Fixes of STEBZ
2026-05-24 09:08:06 -06:00
langou 8515a319e7 Merge pull request #1283 from sergey-v-kuznetsov/fixes_for_issue-1282
Fixes for LAPACK test crashes -ffpe-trap
2026-05-21 03:08:53 -06:00
sergey-v-kuznetsov 40abea27f7 Fixes for LAPACK test crashes -ffpe-trap 2026-05-20 15:41:08 -07:00
Simon Maertens c0e868327e Fixed CBLAS symbol name: cblas_zaxbpy_64 -> cblas_zaxpby_64 2026-05-13 14:03:03 +02:00
langou 67c7c8ac05 Merge pull request #1274 from kyungminlee/fix-sggev3-query
Gate SGGEV3 workspace query on ILV, not ILVL
2026-05-11 07:54:43 -06:00
langou e014d6ce59 Merge pull request #1275 from kyungminlee/fix-dlaswlq-nb
Reject NB=0 in DLASWLQ argument validation
2026-05-11 07:38:43 -06:00
Kyungmin Lee 971961bd21 Gate SGGEV3 workspace query on ILV, not ILVL
The actual SLAQZ0 call uses 'S' when ILV is true and 'E' otherwise,
but the query gated that choice on ILVL, undersizing LWORK for
JOBVL='N', JOBVR='V'. Mirror DGGEV3: gate SLAQZ0 and SGGHD3 on ILV,
SORGQR on ILVL.
2026-05-11 04:58:16 -07:00
Kyungmin Lee f51069fa5e Reject NB=0 in DLASWLQ argument validation
DLASWLQ tested NB.LT.0 instead of NB.LE.0, accepting NB=0 silently and
falling into the divide-by-(NB-M) path on line 255 (KK = MOD((N-M),(NB-M)))
when M=0. The single/complex/double-complex siblings all use NB.LE.0.
2026-05-11 04:38:33 -07:00