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
This commit is contained in:
Julien Schueller
2026-06-11 14:39:38 +02:00
parent fd16118505
commit 3d668fe93f
4 changed files with 48 additions and 32 deletions
+12 -8
View File
@@ -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 ) {
+12 -8
View File
@@ -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 ) {
+12 -8
View File
@@ -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 ) {
+12 -8
View File
@@ -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 ) {