diff --git a/Eigen/src/Core/products/SelfadjointMatrixVector.h b/Eigen/src/Core/products/SelfadjointMatrixVector.h index 10f60266d..f7387601f 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixVector.h +++ b/Eigen/src/Core/products/SelfadjointMatrixVector.h @@ -173,6 +173,11 @@ struct selfadjoint_product_impl { eigen_assert(dest.rows() == a_lhs.rows() && dest.cols() == a_rhs.cols()); + if (a_lhs.rows() == 1) { + dest = (alpha * a_lhs.coeff(0, 0)) * a_rhs; + return; + } + add_const_on_value_type_t lhs = LhsBlasTraits::extract(a_lhs); add_const_on_value_type_t rhs = RhsBlasTraits::extract(a_rhs); diff --git a/test/product_selfadjoint.cpp b/test/product_selfadjoint.cpp index 8d1bda582..b61f30090 100644 --- a/test/product_selfadjoint.cpp +++ b/test/product_selfadjoint.cpp @@ -57,6 +57,10 @@ void product_selfadjoint(const MatrixType& m) { v1.tail(rows - 1) * v2.head(cols - 1).adjoint() + v2.head(cols - 1) * v1.tail(rows - 1).adjoint(); VERIFY_IS_APPROX(m2, m3.template triangularView().toDenseMatrix()); } + + // matrix-vector + m2 = m1.template triangularView(); + VERIFY_IS_APPROX(m1 * m4, m2.template selfadjointView() * m4); } EIGEN_DECLARE_TEST(product_selfadjoint) {