This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1380 - Matrix exponential does not work for mapped matrices
Summary: Matrix exponential does not work for mapped matrices
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Unsupported modules (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Compilation Problem
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-21 20:23 UTC by Yixuan Qiu
Modified: 2019-12-04 16:44 UTC (History)
2 users (show)



Attachments

Description 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 <unsupported/Eigen/MatrixFunctions>
#include <iostream>
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<MatrixXd> 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<MatrixXd>` that does not have a default constructor.


Best,
Yixuan
Comment 2 Yixuan Qiu 2017-01-30 15:34:41 UTC
Thank you Gael.
Comment 3 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<Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> >, double>::run(const Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> >&, Eigen::MatrixBase<Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> > >::PlainObject&, Eigen::MatrixBase<Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> > >::PlainObject&, int&)’
   matrix_exp_computeUV<MatrixType>::run(arg, U, V, squarings); // Pade approximant is (U+V) / (-U+V)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
./unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h:232:15: note: candidate: template<class ArgType> static void Eigen::internal::matrix_exp_computeUV<MatrixType, double>::run(const ArgType&, MatrixType&, MatrixType&, int&) [with ArgType = ArgType; MatrixType = Eigen::Map<Eigen::Matrix<double, -1, -1>, 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<Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> > >::PlainObject {aka Eigen::Matrix<double, -1, -1>}’) to type ‘Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> >&’
   matrix_exp_computeUV<MatrixType>::run(arg, U, V, squarings); // Pade approximant is (U+V) / (-U+V)

=====================================================================


Thanks!


Best,
Yixuan
Comment 4 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)
Comment 5 Nobody 2019-12-04 16:44:39 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1380.

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