diff --git a/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h b/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h index f56990710..e1385358c 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h @@ -84,7 +84,7 @@ EIGEN_BLAS_RANKUPDATE_SPECIALIZE(float) const EIGTYPE* /*rhs*/, Index /*rhsStride*/, EIGTYPE* res, Index resStride, \ EIGTYPE alpha, level3_blocking& /*blocking*/) { \ /* typedef Matrix MatrixRhs;*/ \ - \ + if (size == 0 || depth == 0) return; \ BlasIndex lda = convert_index(lhsStride), ldc = convert_index(resStride), \ n = convert_index(size), k = convert_index(depth); \ char uplo = ((IsLower) ? 'L' : 'U'), trans = ((AStorageOrder == RowMajor) ? 'T' : 'N'); \ @@ -107,7 +107,7 @@ EIGEN_BLAS_RANKUPDATE_SPECIALIZE(float) const EIGTYPE* /*rhs*/, Index /*rhsStride*/, EIGTYPE* res, Index resStride, \ EIGTYPE alpha, level3_blocking& /*blocking*/) { \ typedef Matrix MatrixType; \ - \ + if (size == 0 || depth == 0) return; \ BlasIndex lda = convert_index(lhsStride), ldc = convert_index(resStride), \ n = convert_index(size), k = convert_index(depth); \ char uplo = ((IsLower) ? 'L' : 'U'), trans = ((AStorageOrder == RowMajor) ? 'C' : 'N'); \ diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h b/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h index af64fd277..56743da3b 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h @@ -59,7 +59,7 @@ namespace internal { Index rhsStride, EIGTYPE* res, Index resIncr, Index resStride, EIGTYPE alpha, \ level3_blocking& /*blocking*/, GemmParallelInfo* /*info = 0*/) { \ using std::conj; \ - \ + if (rows == 0 || cols == 0 || depth == 0) return; \ EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \ eigen_assert(resIncr == 1); \ char transa, transb; \ diff --git a/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h b/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h index 556c6aca7..4010a0a67 100644 --- a/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +++ b/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h @@ -95,6 +95,7 @@ EIGEN_BLAS_GEMV_SPECIALIZE(scomplex) \ static void run(Index rows, Index cols, const EIGTYPE* lhs, Index lhsStride, const EIGTYPE* rhs, Index rhsIncr, \ EIGTYPE* res, Index resIncr, EIGTYPE alpha) { \ + if (rows == 0 || cols == 0) return; \ BlasIndex m = convert_index(rows), n = convert_index(cols), \ lda = convert_index(lhsStride), incx = convert_index(rhsIncr), \ incy = convert_index(resIncr); \ @@ -111,8 +112,9 @@ EIGEN_BLAS_GEMV_SPECIALIZE(scomplex) x_tmp = map_x.conjugate(); \ x_ptr = x_tmp.data(); \ incx = 1; \ - } else \ + } else { \ x_ptr = rhs; \ + } \ BLASFUNC(&trans, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)lhs, &lda, \ (const BLASTYPE*)x_ptr, &incx, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &incy); \ } \ diff --git a/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h b/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h index 25daba688..c0dbfd187 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +++ b/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h @@ -49,6 +49,7 @@ namespace internal { static void run(Index rows, Index cols, const EIGTYPE* _lhs, Index lhsStride, const EIGTYPE* _rhs, \ Index rhsStride, EIGTYPE* res, Index resIncr, Index resStride, EIGTYPE alpha, \ level3_blocking& /*blocking*/) { \ + if (rows == 0 || cols == 0) return; \ EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \ eigen_assert(resIncr == 1); \ char side = 'L', uplo = 'L'; \ @@ -91,6 +92,7 @@ namespace internal { static void run(Index rows, Index cols, const EIGTYPE* _lhs, Index lhsStride, const EIGTYPE* _rhs, \ Index rhsStride, EIGTYPE* res, Index resIncr, Index resStride, EIGTYPE alpha, \ level3_blocking& /*blocking*/) { \ + if (rows == 0 || cols == 0) return; \ EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \ eigen_assert(resIncr == 1); \ char side = 'L', uplo = 'L'; \ @@ -164,6 +166,7 @@ EIGEN_BLAS_HEMM_L(scomplex, float, cf, chemm_) static void run(Index rows, Index cols, const EIGTYPE* _lhs, Index lhsStride, const EIGTYPE* _rhs, \ Index rhsStride, EIGTYPE* res, Index resIncr, Index resStride, EIGTYPE alpha, \ level3_blocking& /*blocking*/) { \ + if (rows == 0 || cols == 0) return; \ EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \ eigen_assert(resIncr == 1); \ char side = 'R', uplo = 'L'; \ diff --git a/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h b/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h index c3311daf7..187c9115a 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +++ b/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h @@ -78,6 +78,7 @@ EIGEN_BLAS_SYMV_SPECIALIZE(scomplex) \ static void run(Index size, const EIGTYPE* lhs, Index lhsStride, const EIGTYPE* _rhs, EIGTYPE* res, \ EIGTYPE alpha) { \ + if (size == 0) return; \ enum { IsRowMajor = StorageOrder == RowMajor ? 1 : 0, IsLower = UpLo == Lower ? 1 : 0 }; \ BlasIndex n = convert_index(size), lda = convert_index(lhsStride), incx = 1, incy = 1; \ EIGTYPE beta(1); \ diff --git a/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h b/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h index 78e48ada8..3d612b04d 100644 --- a/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +++ b/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h @@ -90,6 +90,7 @@ EIGEN_BLAS_TRMM_SPECIALIZE(scomplex, false) static void run(Index _rows, Index _cols, Index _depth, const EIGTYPE* _lhs, Index lhsStride, const EIGTYPE* _rhs, \ Index rhsStride, EIGTYPE* res, Index resStride, EIGTYPE alpha, \ level3_blocking& blocking) { \ + if (_rows == 0 || _cols == 0 || _depth == 0) return; \ Index diagSize = (std::min)(_rows, _depth); \ Index rows = IsLower ? _rows : diagSize; \ Index depth = IsLower ? diagSize : _depth; \ @@ -211,6 +212,7 @@ EIGEN_BLAS_TRMM_L(scomplex, float, cf, ctrmm_) static void run(Index _rows, Index _cols, Index _depth, const EIGTYPE* _lhs, Index lhsStride, const EIGTYPE* _rhs, \ Index rhsStride, EIGTYPE* res, Index resStride, EIGTYPE alpha, \ level3_blocking& blocking) { \ + if (_rows == 0 || _cols == 0 || _depth == 0) return; \ Index diagSize = (std::min)(_cols, _depth); \ Index rows = _rows; \ Index depth = IsLower ? _depth : diagSize; \ diff --git a/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h b/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h index 0c1d56b98..1de68803b 100644 --- a/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +++ b/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h @@ -87,6 +87,7 @@ EIGEN_BLAS_TRMV_SPECIALIZE(scomplex) }; \ static void run(Index rows_, Index cols_, const EIGTYPE* lhs_, Index lhsStride, const EIGTYPE* rhs_, \ Index rhsIncr, EIGTYPE* res_, Index resIncr, EIGTYPE alpha) { \ + if (rows_ == 0 || cols_ == 0) return; \ if (ConjLhs || IsZeroDiag) { \ triangular_matrix_vector_product::run( \ rows_, cols_, lhs_, lhsStride, rhs_, rhsIncr, res_, resIncr, alpha); \ @@ -183,6 +184,7 @@ EIGEN_BLAS_TRMV_CM(scomplex, float, cf, c, _) }; \ static void run(Index rows_, Index cols_, const EIGTYPE* lhs_, Index lhsStride, const EIGTYPE* rhs_, \ Index rhsIncr, EIGTYPE* res_, Index resIncr, EIGTYPE alpha) { \ + if (rows_ == 0 || cols_ == 0) return; \ if (IsZeroDiag) { \ triangular_matrix_vector_product::run( \ rows_, cols_, lhs_, lhsStride, rhs_, rhsIncr, res_, resIncr, alpha); \ diff --git a/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h b/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h index ce8fcb9df..9cc15fbd3 100644 --- a/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +++ b/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h @@ -52,6 +52,7 @@ namespace internal { }; \ static void run(Index size, Index otherSize, const EIGTYPE* _tri, Index triStride, EIGTYPE* _other, \ Index otherIncr, Index otherStride, level3_blocking& /*blocking*/) { \ + if (size == 0 || otherSize == 0) return; \ EIGEN_ONLY_USED_FOR_DEBUG(otherIncr); \ eigen_assert(otherIncr == 1); \ BlasIndex m = convert_index(size), n = convert_index(otherSize), lda, ldb; \ @@ -110,6 +111,7 @@ EIGEN_BLAS_TRSM_L(scomplex, float, ctrsm_) }; \ static void run(Index size, Index otherSize, const EIGTYPE* _tri, Index triStride, EIGTYPE* _other, \ Index otherIncr, Index otherStride, level3_blocking& /*blocking*/) { \ + if (size == 0 || otherSize == 0) return; \ EIGEN_ONLY_USED_FOR_DEBUG(otherIncr); \ eigen_assert(otherIncr == 1); \ BlasIndex m = convert_index(otherSize), n = convert_index(size), lda, ldb; \