From 159ab4a043cb82642a589a6c833d26e55d355a54 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 7 May 2009 18:11:49 +0000 Subject: [PATCH] CREDIT Hauke Heibel, windows compatibility fixes in MatrixExponential --- unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h index deb455f47..bc1bcceb2 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h @@ -25,6 +25,10 @@ #ifndef EIGEN_MATRIX_EXPONENTIAL #define EIGEN_MATRIX_EXPONENTIAL +#ifdef _MSC_VER +template Scalar log2(Scalar v) { return std::log(v)/std::log(Scalar(2)); } +#endif + /** Compute the matrix exponential. * * \param M matrix whose exponential is to be computed. @@ -131,7 +135,7 @@ void ei_matrix_exponential(const MatrixBase &M, typename ei_plain_matri squarings = std::max(0, (int)ceil(log2(l1norm / maxnorm))); PlainMatrixType A, A2, A4, A6; - A = M / pow(2, squarings); + A = M / pow(Scalar(2), squarings); A2 = (A * A).lazy(); A4 = (A2 * A2).lazy(); A6 = (A4 * A2).lazy();