-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the MatrixView class #734
Implement the MatrixView class #734
Conversation
…e with make_matrix_view method
…w object is passed to a toEigen() method
ba6bc38
to
c4fe388
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor comment, other then that it is great. The stride trick is far from being intuitive, so if you have some link to explain it would be great to add it in a comment in the code, thanks!
Other then that, can you update the CHANGELOG?
Let me drop here an idea. It would be nice to add (not necessarily in this PR) a |
For the time being we can use |
Co-authored-by: Silvio Traversaro <pegua1@gmail.com>
Yes, but that is not returning a |
…n iDynTree::MatrixView
|
||
// This is a trick required to see a ColMajor matrix as a RowMajor matrix. | ||
const int innerStride = (mat.storageOrder() == StorageOrder::ColMajor) ? mat.rows() : 1; | ||
const int outerStride = (mat.storageOrder() == StorageOrder::ColMajor) ? 1 : mat.cols(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read here that it is not always safe to use ternary operators with Eigen expressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, my bad, here mat is a MatrixView type!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it is not safe when an Eigen type is on the left side. In this case should be fine as only int
are involved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, understood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the operator is called on int
so it shouldn't be a problem, please correct me if I'm mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it is not safe when an Eigen type is on the left side. In this case should be fine as only int are involved.
Ops I missed the message
Thanks! Can I merge with squash? |
Yes sure |
This PR has to be the updated version of #730. Differently from #730 the
storage ordering
is now a regular attribute of the class, rather than a template parameter. The class now behaves like anstd::span
, i.e. when the copy assignment operator is called the pointer, and not what it's contained, is copied.I've also implemented
make_matrix_view
to simplify the creation of aMatrixView
. The usualtoEigen()
functions have been implemented to convert theMatrixView<>
to anEigenMap
, in this case, theStorageOrder
is handled using theEigen::Stride
(thanks @S-Dafarra for suggesting this).The PR is correlated to UnitTests.
This is the first step to achieve #716
@traversaro @prashanthr05 @S-Dafarra
This is a preliminary working implementation of
kindyn
withMatrixView
.