Skip to content

Commit 00ef1bb

Browse files
authored
Merge pull request #4306 from angsch/develop
Improve matcopy interface
2 parents 9c3c1cf + 5ffbe64 commit 00ef1bb

File tree

4 files changed

+56
-48
lines changed

4 files changed

+56
-48
lines changed

interface/imatcopy.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,29 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows,
100100

101101
if ( order == BlasColMajor)
102102
{
103-
if ( trans == BlasNoTrans && *ldb < *rows ) info = 8;
104-
if ( trans == BlasTrans && *ldb < *cols ) info = 8;
103+
if ( trans == BlasNoTrans && *ldb < MAX(1,*rows) ) info = 8;
104+
if ( trans == BlasTrans && *ldb < MAX(1,*cols) ) info = 8;
105105
}
106106
if ( order == BlasRowMajor)
107107
{
108-
if ( trans == BlasNoTrans && *ldb < *cols ) info = 8;
109-
if ( trans == BlasTrans && *ldb < *rows ) info = 8;
108+
if ( trans == BlasNoTrans && *ldb < MAX(1,*cols) ) info = 8;
109+
if ( trans == BlasTrans && *ldb < MAX(1,*rows) ) info = 8;
110110
}
111111

112-
if ( order == BlasColMajor && *lda < *rows ) info = 7;
113-
if ( order == BlasRowMajor && *lda < *cols ) info = 7;
114-
if ( *cols <= 0 ) info = 4;
115-
if ( *rows <= 0 ) info = 3;
116-
if ( trans < 0 ) info = 2;
117-
if ( order < 0 ) info = 1;
112+
if ( order == BlasColMajor && *lda < MAX(1,*rows) ) info = 7;
113+
if ( order == BlasRowMajor && *lda < MAX(1,*cols) ) info = 7;
114+
if ( *cols < 0 ) info = 4;
115+
if ( *rows < 0 ) info = 3;
116+
if ( trans < 0 ) info = 2;
117+
if ( order < 0 ) info = 1;
118118

119119
if (info >= 0) {
120120
BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
121121
return;
122122
}
123123

124+
if ((*rows == 0) || (*cols == 0)) return;
125+
124126
#ifdef NEW_IMATCOPY
125127
if ( *lda == *ldb ) {
126128
if ( order == BlasColMajor )

interface/omatcopy.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,29 @@ void CNAME(enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows,
9090
#endif
9191
if ( order == BlasColMajor)
9292
{
93-
if ( trans == BlasNoTrans && *ldb < *rows ) info = 9;
94-
if ( trans == BlasTrans && *ldb < *cols ) info = 9;
93+
if ( trans == BlasNoTrans && *ldb < MAX(1,*rows) ) info = 9;
94+
if ( trans == BlasTrans && *ldb < MAX(1,*cols) ) info = 9;
9595
}
9696
if ( order == BlasRowMajor)
9797
{
98-
if ( trans == BlasNoTrans && *ldb < *cols ) info = 9;
99-
if ( trans == BlasTrans && *ldb < *rows ) info = 9;
98+
if ( trans == BlasNoTrans && *ldb < MAX(1,*cols) ) info = 9;
99+
if ( trans == BlasTrans && *ldb < MAX(1,*rows) ) info = 9;
100100
}
101101

102-
if ( order == BlasColMajor && *lda < *rows ) info = 7;
103-
if ( order == BlasRowMajor && *lda < *cols ) info = 7;
104-
if ( *cols <= 0 ) info = 4;
105-
if ( *rows <= 0 ) info = 3;
106-
if ( trans < 0 ) info = 2;
107-
if ( order < 0 ) info = 1;
102+
if ( order == BlasColMajor && *lda < MAX(1,*rows) ) info = 7;
103+
if ( order == BlasRowMajor && *lda < MAX(1,*cols) ) info = 7;
104+
if ( *cols < 0 ) info = 4;
105+
if ( *rows < 0 ) info = 3;
106+
if ( trans < 0 ) info = 2;
107+
if ( order < 0 ) info = 1;
108108

109109
if (info >= 0) {
110110
BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
111111
return;
112112
}
113113

114+
if ((*rows == 0) || (*cols == 0)) return;
115+
114116
if ( order == BlasColMajor )
115117
{
116118
if ( trans == BlasNoTrans )

interface/zimatcopy.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,31 +101,33 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows,
101101

102102
if ( order == BlasColMajor)
103103
{
104-
if ( trans == BlasNoTrans && *ldb < *rows ) info = 9;
105-
if ( trans == BlasConj && *ldb < *rows ) info = 9;
106-
if ( trans == BlasTrans && *ldb < *cols ) info = 9;
107-
if ( trans == BlasTransConj && *ldb < *cols ) info = 9;
104+
if ( trans == BlasNoTrans && *ldb < MAX(1,*rows) ) info = 9;
105+
if ( trans == BlasConj && *ldb < MAX(1,*rows) ) info = 9;
106+
if ( trans == BlasTrans && *ldb < MAX(1,*cols) ) info = 9;
107+
if ( trans == BlasTransConj && *ldb < MAX(1,*cols) ) info = 9;
108108
}
109109
if ( order == BlasRowMajor)
110110
{
111-
if ( trans == BlasNoTrans && *ldb < *cols ) info = 9;
112-
if ( trans == BlasConj && *ldb < *cols ) info = 9;
113-
if ( trans == BlasTrans && *ldb < *rows ) info = 9;
114-
if ( trans == BlasTransConj && *ldb < *rows ) info = 9;
111+
if ( trans == BlasNoTrans && *ldb < MAX(1,*cols) ) info = 9;
112+
if ( trans == BlasConj && *ldb < MAX(1,*cols) ) info = 9;
113+
if ( trans == BlasTrans && *ldb < MAX(1,*rows) ) info = 9;
114+
if ( trans == BlasTransConj && *ldb < MAX(1,*rows) ) info = 9;
115115
}
116116

117-
if ( order == BlasColMajor && *lda < *rows ) info = 7;
118-
if ( order == BlasRowMajor && *lda < *cols ) info = 7;
119-
if ( *cols <= 0 ) info = 4;
120-
if ( *rows <= 0 ) info = 3;
121-
if ( trans < 0 ) info = 2;
122-
if ( order < 0 ) info = 1;
117+
if ( order == BlasColMajor && *lda < MAX(1,*rows) ) info = 7;
118+
if ( order == BlasRowMajor && *lda < MAX(1,*cols) ) info = 7;
119+
if ( *cols < 0 ) info = 4;
120+
if ( *rows < 0 ) info = 3;
121+
if ( trans < 0 ) info = 2;
122+
if ( order < 0 ) info = 1;
123123

124124
if (info >= 0) {
125125
BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
126126
return;
127127
}
128128

129+
if ((*rows == 0) || (*cols == 0)) return;
130+
129131
#ifdef NEW_IMATCOPY
130132
if (*lda == *ldb ) {
131133
if ( order == BlasColMajor )

interface/zomatcopy.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,31 +92,33 @@ void CNAME(enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows,
9292
#endif
9393
if ( order == BlasColMajor)
9494
{
95-
if ( trans == BlasNoTrans && *ldb < *rows ) info = 9;
96-
if ( trans == BlasConj && *ldb < *rows ) info = 9;
97-
if ( trans == BlasTrans && *ldb < *cols ) info = 9;
98-
if ( trans == BlasTransConj && *ldb < *cols ) info = 9;
95+
if ( trans == BlasNoTrans && *ldb < MAX(1,*rows) ) info = 9;
96+
if ( trans == BlasConj && *ldb < MAX(1,*rows) ) info = 9;
97+
if ( trans == BlasTrans && *ldb < MAX(1,*cols) ) info = 9;
98+
if ( trans == BlasTransConj && *ldb < MAX(1,*cols) ) info = 9;
9999
}
100100
if ( order == BlasRowMajor)
101101
{
102-
if ( trans == BlasNoTrans && *ldb < *cols ) info = 9;
103-
if ( trans == BlasConj && *ldb < *cols ) info = 9;
104-
if ( trans == BlasTrans && *ldb < *rows ) info = 9;
105-
if ( trans == BlasTransConj && *ldb < *rows ) info = 9;
102+
if ( trans == BlasNoTrans && *ldb < MAX(1,*cols) ) info = 9;
103+
if ( trans == BlasConj && *ldb < MAX(1,*cols) ) info = 9;
104+
if ( trans == BlasTrans && *ldb < MAX(1,*rows) ) info = 9;
105+
if ( trans == BlasTransConj && *ldb < MAX(1,*rows) ) info = 9;
106106
}
107107

108-
if ( order == BlasColMajor && *lda < *rows ) info = 7;
109-
if ( order == BlasRowMajor && *lda < *cols ) info = 7;
110-
if ( *cols <= 0 ) info = 4;
111-
if ( *rows <= 0 ) info = 3;
112-
if ( trans < 0 ) info = 2;
113-
if ( order < 0 ) info = 1;
108+
if ( order == BlasColMajor && *lda < MAX(1,*rows) ) info = 7;
109+
if ( order == BlasRowMajor && *lda < MAX(1,*cols) ) info = 7;
110+
if ( *cols < 0 ) info = 4;
111+
if ( *rows < 0 ) info = 3;
112+
if ( trans < 0 ) info = 2;
113+
if ( order < 0 ) info = 1;
114114

115115
if (info >= 0) {
116116
BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
117117
return;
118118
}
119119

120+
if ((*rows == 0) || (*cols == 0)) return;
121+
120122
if ( order == BlasColMajor )
121123
{
122124

0 commit comments

Comments
 (0)