New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 1380 - Matrix exponential does not work for mapped matrices
Matrix exponential does not work for mapped matrices
 Status: RESOLVED FIXED None Eigen Unclassified Unsupported modules (show other bugs) 3.3 (current stable) All All Normal Compilation Problem Nobody

 Reported: 2017-01-21 20:23 UTC by Yixuan Qiu 2017-02-20 13:07 UTC (History) 2 users (show) chtz gael.guennebaud

Attachments

 Yixuan Qiu 2017-01-21 20:23:56 UTC ```Hi All, It looks like that on the 3.3 branch, matrix exponential (from the unsupported module) no longer works for mapped matrices. Below is an example, modified from the documentation: ===================================================================== #include #include using namespace Eigen; int main() { const double pi = std::acos(-1.0); MatrixXd A(3, 3); A << 0, -pi/4, 0, pi/4, 0, 0, 0, 0, 0; std::cout << "The matrix A is:\n" << A << "\n\n"; std::cout << "The matrix exponential of A is:\n" << A.exp() << "\n\n"; // fine Map B(A.data(), 3, 3); std::cout << "The matrix B is:\n" << B << "\n\n"; std::cout << "The matrix exponential of B is:\n" << B.exp() << "\n\n"; // fails on Eigen 3.3 return 0; } ===================================================================== This is due to this line: https://bitbucket.org/eigen/eigen/src/0f635ff77c58/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h?at=default&fileviewer=file-view-default#MatrixExponential.h-354, where `MatrixType` is `Map` that does not have a default constructor. Best, Yixuan``` Gael Guennebaud 2017-01-30 12:57:23 UTC ```Fixed: https://bitbucket.org/eigen/eigen/commits/9210b3d60b03/ (devel) https://bitbucket.org/eigen/eigen/commits/c6dc8157ad27/ (3.3)``` Yixuan Qiu 2017-01-30 15:34:41 UTC `Thank you Gael.` Yixuan Qiu 2017-02-18 22:51:23 UTC ```Hi Gael, I have tried this patch, but it seems that the problem has not been fully resolved. I compiled the example code above under the newest 3.3 branch, and it generated the following errors: ===================================================================== ./unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h:359:40: error: no matching function for call to ‘Eigen::internal::matrix_exp_computeUV, 0, Eigen::Stride<0, 0> >, double>::run(const Eigen::Map, 0, Eigen::Stride<0, 0> >&, Eigen::MatrixBase, 0, Eigen::Stride<0, 0> > >::PlainObject&, Eigen::MatrixBase, 0, Eigen::Stride<0, 0> > >::PlainObject&, int&)’ matrix_exp_computeUV::run(arg, U, V, squarings); // Pade approximant is (U+V) / (-U+V) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ ./unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h:232:15: note: candidate: template static void Eigen::internal::matrix_exp_computeUV::run(const ArgType&, MatrixType&, MatrixType&, int&) [with ArgType = ArgType; MatrixType = Eigen::Map, 0, Eigen::Stride<0, 0> >] static void run(const ArgType& arg, MatrixType& U, MatrixType& V, int& squarings) ^~~ ./unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h:232:15: note: template argument deduction/substitution failed: ./unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h:359:40: note: cannot convert ‘U’ (type ‘Eigen::MatrixBase, 0, Eigen::Stride<0, 0> > >::PlainObject {aka Eigen::Matrix}’) to type ‘Eigen::Map, 0, Eigen::Stride<0, 0> >&’ matrix_exp_computeUV::run(arg, U, V, squarings); // Pade approximant is (U+V) / (-U+V) ===================================================================== Thanks! Best, Yixuan``` Gael Guennebaud 2017-02-20 13:07:55 UTC ```Right, here is a more complete fix: https://bitbucket.org/eigen/eigen/commits/cf029096b7b7/ (devel) https://bitbucket.org/eigen/eigen/commits/a19f8531ea35/ (3.3)```

 Note You need to log in before you can comment on or make changes to this bug.