Registered Member
|
Hi again!
I wonder if there is any form of accessing the data buffer of a Matrix object? I'm looking for something like double *buffer = eigenMatrix.Data(); I need to interface Eigen Matrixes with a legacy Matrix class, there is a lot of code already written for this legacy class, so changing it to Eigen matrix is not an option atm. So far I'm using a Map in this way: double *buffer = legacyMatrix.Data(); Map<MatrixXd> mapMatrix(buffer, rows, cols); .... operate my mapMatrix .... .... pass my legacyMatrix to another function .... However, now I'm using some legacy debug functions to compare numeric accuracy with Matlab counterparts, and I'm having to rename and replicate the structure above lots of times, which is getting annoying. I tried to assign a Eigen::Matrix to a generic Eigen::Map that is already mapped to the legacyMatrix, it builds but gives a runtime exception. As a last resource I'll copy the elements of the Eigen::Matrix manually, which for debuging it's not a problem, but it would be nice it I could do the double *buffer = eigenMatrix.Data(); Thanks, Martin. |
Registered Member
|
You got it almost right, it's .data() (notice lowercase d)
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Hi bjacob,
Thanks for your reply. For some reason I couldn't access the forum all yesterday. I hope I wasn't banned for asking a too obvious question I guess it's obvious it would be .data(), although I haven't been able to find that in the Eigen documentation, is that an undocumented method? Cheers Martin |
Registered Member
|
Oh! now I see what happens.
The .data() method appears in the stable branch documentation but not in the development branch, and that's the one I was looking in. Well thanks again. Martin. |
Registered Member
|
In the development branch, the .data() method is in the DenseStorageBase class, documented at http://eigen.tuxfamily.org/dox-devel/classEigen_1_1DenseStorageBase.html . The Matrix class inherits the DenseStorageBase class. Unfortunately, the automatically generated documentation does not show this inheritance, so I cannot blame you for not finding this. I guess that Eigen's template-heavy inheritance tree is too complicated for doxygen. You can read a bit about Eigen's class hierarchy at http://eigen.tuxfamily.org/dox-devel/TopicClassHierarchy.html .
|
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]