Skip to content

Commit 328d4bc

Browse files
prj-PierreMarchand20
authored andcommitted
Avoid empty-sized gemv
BLAS error: Parameter lda passed to cblas_zgemv was 0, which is invalid.
1 parent d7c0fa8 commit 328d4bc

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ All notable changes to this project will be documented in this file.
3232

3333
### Fixed
3434

35+
- Avoid empty-sized gemv, PR #64 from @prj-
36+
3537
## [1.0.0] - 2027-09-24
3638

3739
### Added

include/htool/matrix/linalg/add_matrix_vector_product.hpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ namespace htool {
88

99
template <typename T>
1010
void add_matrix_vector_product(char trans, T alpha, const Matrix<T> &A, const T *in, T beta, T *out) {
11-
int nr = A.nb_rows();
12-
int nc = A.nb_cols();
13-
int lda = nr;
14-
int incx = 1;
15-
int incy = 1;
16-
Blas<T>::gemv(&trans, &nr, &nc, &alpha, A.data(), &lda, in, &incx, &beta, out, &incy);
11+
int nr = A.nb_rows();
12+
int nc = A.nb_cols();
13+
int lda = nr;
14+
15+
if (nr && nc) {
16+
int incx = 1;
17+
int incy = 1;
18+
Blas<T>::gemv(&trans, &nr, &nc, &alpha, A.data(), &lda, in, &incx, &beta, out, &incy);
19+
} else if (nr) {
20+
std::transform(out, out + nr, out, [&beta](T &c) { return c * beta; }); // LCOV_EXCL_LINE
21+
}
1722
}
1823

1924
template <typename T>

0 commit comments

Comments
 (0)