Matrix exponential does not work for mapped matrices
Submitted by Yixuan Qiu
Assigned to Nobody
Link to original bugzilla bug (#1380)
Version: 3.3 (current stable)
Description
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/924600a0e817d5200a8841ce6577ef372dcc209c/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