Skip to content

Commit 6797a3a

Browse files
authored
Add early returns
1 parent 936966a commit 6797a3a

File tree

10 files changed

+34
-7
lines changed

10 files changed

+34
-7
lines changed

relapack/src/cgetrf.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ void RELAPACK_cgetrf(
3030
return;
3131
}
3232

33+
if (*m == 0 || *n == 0) return;
34+
3335
const blasint sn = MIN(*m, *n);
3436

3537
RELAPACK_cgetrf_rec(m, &sn, A, ldA, ipiv, info);
@@ -62,9 +64,11 @@ static void RELAPACK_cgetrf_rec(
6264
blasint *info
6365
) {
6466

65-
if (*n <= MAX(CROSSOVER_CGETRF, 1)) {
67+
if (*m == 0 || *n == 0) return;
68+
69+
if ( *n <= MAX(CROSSOVER_CGETRF, 1)) {
6670
// Unblocked
67-
LAPACK(cgetf2)(m, n, A, ldA, ipiv, info);
71+
LAPACK(cgetrf2)(m, n, A, ldA, ipiv, info);
6872
return;
6973
}
7074

@@ -96,6 +100,7 @@ static void RELAPACK_cgetrf_rec(
96100

97101
// recursion(A_L, ipiv_T)
98102
RELAPACK_cgetrf_rec(m, &n1, A_L, ldA, ipiv_T, info);
103+
if (*info) return;
99104
// apply pivots to A_R
100105
LAPACK(claswp)(&n2, A_R, ldA, iONE, &n1, ipiv_T, iONE);
101106

relapack/src/chegst.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ void RELAPACK_chegst(
4040
return;
4141
}
4242

43+
if (*n == 0) return;
44+
4345
// Clean char * arguments
4446
const char cleanuplo = lower ? 'L' : 'U';
4547

relapack/src/chetrf_rook.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void RELAPACK_chetrf_rook(
3636
*info = -2;
3737
else if (*ldA < MAX(1, *n))
3838
*info = -4;
39-
else if (*lWork < minlWork && *lWork != -1)
39+
else if ((*lWork < 1 || *lWork < minlWork) && *lWork != -1)
4040
*info = -7;
4141
else if (*lWork == -1) {
4242
// Work size query
@@ -56,7 +56,7 @@ void RELAPACK_chetrf_rook(
5656

5757
if (*info) {
5858
const blasint minfo = -*info;
59-
LAPACK(xerbla)("CHETRF", &minfo, strlen("CHETRF"));
59+
LAPACK(xerbla)("CHETRF_ROOK", &minfo, strlen("CHETRF_ROOK"));
6060
return;
6161
}
6262

relapack/src/clauum.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ void RELAPACK_clauum(
3232
return;
3333
}
3434

35+
if (*n == 0) return;
36+
3537
// Clean char * arguments
3638
const char cleanuplo = lower ? 'L' : 'U';
3739

relapack/src/cpotrf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ void RELAPACK_cpotrf(
3232
return;
3333
}
3434

35+
if (*n == 0) return;
36+
3537
// Clean char * arguments
3638
const char cleanuplo = lower ? 'L' : 'U';
3739

@@ -46,6 +48,7 @@ static void RELAPACK_cpotrf_rec(
4648
float *A, const blasint *ldA,
4749
blasint *info
4850
){
51+
if (*n == 0) return;
4952

5053
if (*n <= MAX(CROSSOVER_CPOTRF, 1)) {
5154
// Unblocked

relapack/src/csytrf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void RELAPACK_csytrf(
3636
*info = -2;
3737
else if (*ldA < MAX(1, *n))
3838
*info = -4;
39-
else if (*lWork < minlWork && *lWork != -1)
39+
else if ((*lWork < 1 || *lWork < minlWork) && *lWork != -1)
4040
*info = -7;
4141
else if (*lWork == -1) {
4242
// Work size query
@@ -67,6 +67,7 @@ void RELAPACK_csytrf(
6767
blasint nout;
6868

6969
// Recursive kernel
70+
if (*n != 0)
7071
RELAPACK_csytrf_rec(&cleanuplo, n, n, &nout, A, ldA, ipiv, cleanWork, n, info);
7172

7273
#if XSYTRF_ALLOW_MALLOC

relapack/src/csytrf_rook.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void RELAPACK_csytrf_rook(
3636
*info = -2;
3737
else if (*ldA < MAX(1, *n))
3838
*info = -4;
39-
else if (*lWork < minlWork && *lWork != -1)
39+
else if ((*lWork < 1 || *lWork < minlWork) && *lWork != -1)
4040
*info = -7;
4141
else if (*lWork == -1) {
4242
// Work size query
@@ -56,7 +56,7 @@ void RELAPACK_csytrf_rook(
5656

5757
if (*info) {
5858
const blasint minfo = -*info;
59-
LAPACK(xerbla)("CSYTRF", &minfo, strlen("CSYTRF"));
59+
LAPACK(xerbla)("CSYTRF_ROOK", &minfo, strlen("CSYTRF_ROOK"));
6060
return;
6161
}
6262

relapack/src/ctgsyl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ void RELAPACK_ctgsyl(
6868
return;
6969
}
7070

71+
if ( *m == 0 || *n == 0) {
72+
*scale = 1.;
73+
if (notran && (*ijob != 0))
74+
*dif = 0.;
75+
return;
76+
}
77+
7178
// Clean char * arguments
7279
const char cleantrans = notran ? 'N' : 'C';
7380

relapack/src/ctrsyl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ void RELAPACK_ctrsyl(
4747
return;
4848
}
4949

50+
if (*m == 0 || *n == 0) {
51+
*scale = 1.;
52+
return;
53+
}
54+
5055
// Clean char * arguments
5156
const char cleantranA = notransA ? 'N' : 'C';
5257
const char cleantranB = notransB ? 'N' : 'C';

relapack/src/ctrtri.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ void RELAPACK_ctrtri(
3636
return;
3737
}
3838

39+
if (*n == 0) return;
40+
3941
// Clean char * arguments
4042
const char cleanuplo = lower ? 'L' : 'U';
4143
const char cleandiag = nounit ? 'N' : 'U';

0 commit comments

Comments
 (0)