diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h b/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h --- a/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h @@ -301,6 +301,7 @@ res(0,0) = std::pow(m_A(0,0), p); break; case 2: + res.resize(2, 2); compute2x2(res, p); break; default: @@ -320,6 +321,7 @@ res += MatrixType::Identity(IminusT.rows(), IminusT.cols()); } +// this function assumes that res has the correct size (see bug 614) template void MatrixPowerTriangularAtomic::compute2x2(MatrixType& res, RealScalar p) const { diff --git a/unsupported/test/matrix_power.cpp b/unsupported/test/matrix_power.cpp --- a/unsupported/test/matrix_power.cpp +++ b/unsupported/test/matrix_power.cpp @@ -181,6 +181,6 @@ CALL_SUBTEST_1(testMatrixVector(Matrix2f(), Vector2f(), 1e-4)); CALL_SUBTEST_5(testMatrixVector(Matrix3cf(), Vector3cf(), 1e-4)); CALL_SUBTEST_8(testMatrixVector(Matrix4f(), Vector4f(), 1e-4)); - CALL_SUBTEST_6(testMatrixVector(MatrixXf(8,8), VectorXf(8), 1e-3)); + CALL_SUBTEST_6(testMatrixVector(MatrixXf(2,2), VectorXf(2), 1e-3)); // see bug 614 CALL_SUBTEST_9(testMatrixVector(MatrixXe(7,7), VectorXe(7), 1e-13)); }