From 7e64f78f65db6681e6f71b80fa84c57bbce8200f Mon Sep 17 00:00:00 2001 From: Chen-Pang He Date: Sat, 22 Sep 2012 22:06:22 +0800 Subject: [PATCH] Avoid inefficient 2x2 LU --- unsupported/Eigen/src/MatrixFunctions/MatrixPower.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h b/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h index 2ed319641..08affb2b5 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h @@ -226,7 +226,7 @@ void MatrixPower::computeIntPower(const PlainObject& b, ResultType& else if (p>0) { m_tmp1 = m_A; } - else if (b.cols() * (pp - applyings) <= m_A.cols() * squarings) { + else if (m_A.cols() > 2 && b.cols()*(pp-applyings) <= m_A.cols()*squarings) { PartialPivLU A(m_A); res = A.solve(b); for (--pp; pp >= 1; --pp) @@ -237,7 +237,7 @@ void MatrixPower::computeIntPower(const PlainObject& b, ResultType& m_tmp1 = m_A.inverse(); } - while (b.cols() * (pp - applyings) > m_A.cols() * squarings) { + while (b.cols()*(pp-applyings) > m_A.cols()*squarings) { if (std::fmod(pp, 2) >= 1) { apply(b, res, init); --applyings;