diff --git a/Eigen/src/Eigenvalues/ComplexQZ.h b/Eigen/src/Eigenvalues/ComplexQZ.h index de35698ae..ed32ea3da 100644 --- a/Eigen/src/Eigenvalues/ComplexQZ.h +++ b/Eigen/src/Eigenvalues/ComplexQZ.h @@ -565,7 +565,9 @@ void ComplexQZ::push_down_zero_ST(Index k, Index l) { for (Index j = k + 1; j <= l; j++) { // Create a 0 at _T(j, j) J.makeGivens(m_T(j - 1, j), m_T(j, j), &m_T.coeffRef(j - 1, j)); - m_T.rightCols(m_n - j - 1).applyOnTheLeft(j - 1, j, J.adjoint()); + if (m_n - j - 1 > 0) { + m_T.rightCols(m_n - j - 1).applyOnTheLeft(j - 1, j, J.adjoint()); + } m_T.coeffRef(j, j) = Scalar(0); m_S.applyOnTheLeft(j - 1, j, J.adjoint()); diff --git a/test/complex_qz.cpp b/test/complex_qz.cpp index a6b05dc92..28ab08e93 100644 --- a/test/complex_qz.cpp +++ b/test/complex_qz.cpp @@ -18,11 +18,9 @@ template void generate_random_matrix_pair(const Index dim, MatrixType& A, MatrixType& B) { - A.resize(dim, dim); - B.resize(dim, dim); - A.setRandom(); - B.setRandom(); - // Set each row of B with a probability of 10% to 0 + A.setRandom(dim, dim); + B.setRandom(dim, dim); + // Zero out each row of B to with a probability of 10%. for (int i = 0; i < dim; i++) { if (internal::random(0, 10) == 0) B.row(i).setZero(); } @@ -59,8 +57,6 @@ void complex_qz(const MatrixType& A, const MatrixType& B) { } EIGEN_DECLARE_TEST(complex_qz) { - // const Index dim1 = 15; - // const Index dim2 = 80; for (int i = 0; i < g_repeat; i++) { // Check for very small, fixed-sized double- and float complex matrices Eigen::Matrix2cd A_2x2, B_2x2; @@ -71,16 +67,18 @@ EIGEN_DECLARE_TEST(complex_qz) { A_3x3.setRandom(); B_3x3.setRandom(); B_3x3.col(i % 3).setRandom(); - // Test for small float complex matrices - Eigen::MatrixXcf A_float, B_float; - const Index dim1 = internal::random(15, 80), dim2 = internal::random(15, 80); - generate_random_matrix_pair(dim1, A_float, B_float); - // Test for a bit larger double complex matrices - Eigen::MatrixXcd A_double, B_double; - generate_random_matrix_pair(dim2, A_double, B_double); CALL_SUBTEST_1(complex_qz(A_2x2, B_2x2)); CALL_SUBTEST_2(complex_qz(A_3x3, B_3x3)); + + // Test for float complex matrices + const Index dim = internal::random(15, 80); + Eigen::MatrixXcf A_float, B_float; + generate_random_matrix_pair(dim, A_float, B_float); CALL_SUBTEST_3(complex_qz(A_float, B_float)); + + // Test for double complex matrices + Eigen::MatrixXcd A_double, B_double; + generate_random_matrix_pair(dim, A_double, B_double); CALL_SUBTEST_4(complex_qz(A_double, B_double)); } }