diff --git a/unsupported/Eigen/MPRealSupport b/unsupported/Eigen/MPRealSupport index 30e8d66e4..8f6132946 100644 --- a/unsupported/Eigen/MPRealSupport +++ b/unsupported/Eigen/MPRealSupport @@ -30,6 +30,7 @@ #ifndef EIGEN_MPREALSUPPORT_MODULE_H #define EIGEN_MPREALSUPPORT_MODULE_H +#include #include #include @@ -51,7 +52,7 @@ namespace Eigen { * \code #include -#include +#include #include using namespace mpfr; using namespace Eigen; diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h index 2b014682d..29ec7e393 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h @@ -26,6 +26,8 @@ #ifndef EIGEN_MATRIX_EXPONENTIAL #define EIGEN_MATRIX_EXPONENTIAL +#include "StemFunction.h" + #ifdef _MSC_VER template Scalar log2(Scalar v) { using std::log; return log(v)/log(Scalar(2)); } #endif @@ -148,6 +150,7 @@ class MatrixExponential { typedef typename internal::traits::Scalar Scalar; typedef typename NumTraits::Real RealScalar; + typedef typename std::complex ComplexScalar; /** \brief Reference to matrix whose exponential is to be computed. */ typename internal::nested::type m_M; @@ -183,7 +186,7 @@ MatrixExponential::MatrixExponential(const MatrixType &M) : m_tmp2(M.rows(),M.cols()), m_Id(MatrixType::Identity(M.rows(), M.cols())), m_squarings(0), - m_l1norm(static_cast(M.cwiseAbs().colwise().sum().maxCoeff())) + m_l1norm(M.cwiseAbs().colwise().sum().maxCoeff()) { /* empty body */ } @@ -192,12 +195,16 @@ template template void MatrixExponential::compute(ResultType &result) { - computeUV(RealScalar()); - m_tmp1 = m_U + m_V; // numerator of Pade approximant - m_tmp2 = -m_U + m_V; // denominator of Pade approximant - result = m_tmp2.partialPivLu().solve(m_tmp1); - for (int i=0; i::exp); + } } template @@ -386,11 +393,9 @@ void MatrixExponential::computeUV(long double) MatrixType A = m_M / pow(Scalar(2), m_squarings); pade17(A); } -#else // should never happen - MatrixType A = m_M / Scalar(2); - m_U = m_M.sinh(); - m_V = m_M.cosh(); -#endif +#else // rarely happens + throw 0; // will be caught +#endif // LDBL_MANT_DIG } /** \ingroup MatrixFunctions_Module