From 3d668fe93f517caeb411d7ac2ea7d074db775b04 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Wed, 10 Jun 2026 14:06:51 +0200 Subject: [PATCH] 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 --- LAPACKE/src/lapacke_cgesvd_work.c | 20 ++++++++++++-------- LAPACKE/src/lapacke_dgesvd_work.c | 20 ++++++++++++-------- LAPACKE/src/lapacke_sgesvd_work.c | 20 ++++++++++++-------- LAPACKE/src/lapacke_zgesvd_work.c | 20 ++++++++++++-------- 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/LAPACKE/src/lapacke_cgesvd_work.c b/LAPACKE/src/lapacke_cgesvd_work.c index 5045150ff..280ae63cd 100644 --- a/LAPACKE/src/lapacke_cgesvd_work.c +++ b/LAPACKE/src/lapacke_cgesvd_work.c @@ -69,15 +69,19 @@ lapack_int API_SUFFIX(LAPACKE_cgesvd_work)( int matrix_layout, char jobu, char j API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_cgesvd_work", info ); return info; } - if( ldu < ncols_u ) { - info = -10; - API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_cgesvd_work", info ); - return info; + if( API_SUFFIX(LAPACKE_lsame)( jobu, 'a' ) || API_SUFFIX(LAPACKE_lsame)( jobu, 's' ) ) { + if( ldu < ncols_u ) { + info = -10; + API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_cgesvd_work", info ); + return info; + } } - if( ldvt < ncols_vt ) { - info = -12; - API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_cgesvd_work", info ); - return info; + if( API_SUFFIX(LAPACKE_lsame)( jobvt, 'a' ) || API_SUFFIX(LAPACKE_lsame)( jobvt, 's' ) ) { + if( ldvt < ncols_vt ) { + info = -12; + API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_cgesvd_work", info ); + return info; + } } /* Query optimal working array(s) size if requested */ if( lwork == -1 ) { diff --git a/LAPACKE/src/lapacke_dgesvd_work.c b/LAPACKE/src/lapacke_dgesvd_work.c index 99e27cfbd..f5a58b314 100644 --- a/LAPACKE/src/lapacke_dgesvd_work.c +++ b/LAPACKE/src/lapacke_dgesvd_work.c @@ -67,15 +67,19 @@ lapack_int API_SUFFIX(LAPACKE_dgesvd_work)( int matrix_layout, char jobu, char j API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_dgesvd_work", info ); return info; } - if( ldu < ncols_u ) { - info = -10; - API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_dgesvd_work", info ); - return info; + if( API_SUFFIX(LAPACKE_lsame)( jobu, 'a' ) || API_SUFFIX(LAPACKE_lsame)( jobu, 's' ) ) { + if( ldu < ncols_u ) { + info = -10; + API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_dgesvd_work", info ); + return info; + } } - if( ldvt < ncols_vt ) { - info = -12; - API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_dgesvd_work", info ); - return info; + if( API_SUFFIX(LAPACKE_lsame)( jobvt, 'a' ) || API_SUFFIX(LAPACKE_lsame)( jobvt, 's' ) ) { + if( ldvt < ncols_vt ) { + info = -12; + API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_dgesvd_work", info ); + return info; + } } /* Query optimal working array(s) size if requested */ if( lwork == -1 ) { diff --git a/LAPACKE/src/lapacke_sgesvd_work.c b/LAPACKE/src/lapacke_sgesvd_work.c index f339db2f2..87cf9bb62 100644 --- a/LAPACKE/src/lapacke_sgesvd_work.c +++ b/LAPACKE/src/lapacke_sgesvd_work.c @@ -67,15 +67,19 @@ lapack_int API_SUFFIX(LAPACKE_sgesvd_work)( int matrix_layout, char jobu, char j API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_sgesvd_work", info ); return info; } - if( ldu < ncols_u ) { - info = -10; - API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_sgesvd_work", info ); - return info; + if( API_SUFFIX(LAPACKE_lsame)( jobu, 'a' ) || API_SUFFIX(LAPACKE_lsame)( jobu, 's' ) ) { + if( ldu < ncols_u ) { + info = -10; + API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_sgesvd_work", info ); + return info; + } } - if( ldvt < ncols_vt ) { - info = -12; - API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_sgesvd_work", info ); - return info; + if( API_SUFFIX(LAPACKE_lsame)( jobvt, 'a' ) || API_SUFFIX(LAPACKE_lsame)( jobvt, 's' ) ) { + if( ldvt < ncols_vt ) { + info = -12; + API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_sgesvd_work", info ); + return info; + } } /* Query optimal working array(s) size if requested */ if( lwork == -1 ) { diff --git a/LAPACKE/src/lapacke_zgesvd_work.c b/LAPACKE/src/lapacke_zgesvd_work.c index 71af24e0a..0f036dd0e 100644 --- a/LAPACKE/src/lapacke_zgesvd_work.c +++ b/LAPACKE/src/lapacke_zgesvd_work.c @@ -69,15 +69,19 @@ lapack_int API_SUFFIX(LAPACKE_zgesvd_work)( int matrix_layout, char jobu, char j API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_zgesvd_work", info ); return info; } - if( ldu < ncols_u ) { - info = -10; - API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_zgesvd_work", info ); - return info; + if( API_SUFFIX(LAPACKE_lsame)( jobu, 'a' ) || API_SUFFIX(LAPACKE_lsame)( jobu, 's' ) ) { + if( ldu < ncols_u ) { + info = -10; + API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_zgesvd_work", info ); + return info; + } } - if( ldvt < ncols_vt ) { - info = -12; - API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_zgesvd_work", info ); - return info; + if( API_SUFFIX(LAPACKE_lsame)( jobvt, 'a' ) || API_SUFFIX(LAPACKE_lsame)( jobvt, 's' ) ) { + if( ldvt < ncols_vt ) { + info = -12; + API_SUFFIX(LAPACKE_xerbla)( "LAPACKE_zgesvd_work", info ); + return info; + } } /* Query optimal working array(s) size if requested */ if( lwork == -1 ) {