Skip to content

Commit d64cc2b

Browse files
authored
Add early returns
1 parent c9b6714 commit d64cc2b

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

relapack/src/sgetrf.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ void RELAPACK_sgetrf(
1414
float *A, const blasint *ldA, blasint *ipiv,
1515
blasint *info
1616
) {
17-
1817
// Check arguments
1918
*info = 0;
2019
if (*m < 0)
@@ -28,14 +27,17 @@ void RELAPACK_sgetrf(
2827
LAPACK(xerbla)("SGETRF", &minfo, strlen("SGETRF"));
2928
return;
3029
}
30+
31+
if (*m == 0 || *n == 0) return;
32+
3133
const blasint sn = MIN(*m, *n);
3234
RELAPACK_sgetrf_rec(m, &sn, A, ldA, ipiv, info);
3335

3436
// Right remainder
3537
if (*m < *n) {
3638
// Constants
3739
const float ONE[] = { 1. };
38-
const blasint iONE[] = { 1. };
40+
const blasint iONE[] = { 1 };
3941

4042
// Splitting
4143
const blasint rn = *n - *m;
@@ -58,9 +60,12 @@ static void RELAPACK_sgetrf_rec(
5860
float *A, const blasint *ldA, blasint *ipiv,
5961
blasint *info
6062
) {
61-
if (*n <= MAX(CROSSOVER_SGETRF, 1)) {
63+
64+
if (*m == 0 || *n == 0) return;
65+
66+
if ( *n <= MAX(CROSSOVER_SGETRF, 1)) {
6267
// Unblocked
63-
LAPACK(sgetf2)(m, n, A, ldA, ipiv, info);
68+
LAPACK(sgetrf2)(m, n, A, ldA, ipiv, info);
6469
return;
6570
}
6671

@@ -91,6 +96,8 @@ static void RELAPACK_sgetrf_rec(
9196

9297
// recursion(A_L, ipiv_T)
9398
RELAPACK_sgetrf_rec(m, &n1, A_L, ldA, ipiv_T, info);
99+
if (*info)
100+
return;
94101
// apply pivots to A_R
95102
LAPACK(slaswp)(&n2, A_R, ldA, iONE, &n1, ipiv_T, iONE);
96103

relapack/src/ssytrf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void RELAPACK_ssytrf(
3535
*info = -2;
3636
else if (*ldA < MAX(1, *n))
3737
*info = -4;
38-
else if (*lWork < minlWork && *lWork != -1)
38+
else if ((*lWork <1 || *lWork < minlWork) && *lWork != -1)
3939
*info = -7;
4040
else if (*lWork == -1) {
4141
// Work size query
@@ -66,6 +66,7 @@ void RELAPACK_ssytrf(
6666
blasint nout;
6767

6868
// Recursive kernel
69+
if (*n != 0)
6970
RELAPACK_ssytrf_rec(&cleanuplo, n, n, &nout, A, ldA, ipiv, cleanWork, n, info);
7071

7172
#if XSYTRF_ALLOW_MALLOC

relapack/src/ssytrf_rook.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void RELAPACK_ssytrf_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_ssytrf_rook(
5656

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

@@ -67,6 +67,7 @@ void RELAPACK_ssytrf_rook(
6767
blasint nout;
6868

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

7273
#if XSYTRF_ALLOW_MALLOC

relapack/src/strsyl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ void RELAPACK_strsyl(
4949
return;
5050
}
5151

52+
if (*m == 0 || *n == 0) {
53+
*scale = 1.;
54+
return;
55+
}
56+
5257
// Clean char * arguments
5358
const char cleantranA = notransA ? 'N' : (transA ? 'T' : 'C');
5459
const char cleantranB = notransB ? 'N' : (transB ? 'T' : 'C');

0 commit comments

Comments
 (0)