![]() Registered Member ![]()
|
Hello,
I've developped my own wrapper for an old matrix library and it works fine. I'm now trying use Eigen 3 Beta to see if my code is faster. I download the beta version a couple of days after it was released just to test with openmp and I download it again this morning but my previous code doesn't work. Indeed I can't now do derived(i,j) to access to the element (i,j), I need to add .coeff or .coeffRef .Do I miss something or need I to change my code ? (I use #define EIGEN2_SUPPORT) Thanks ![]() |
![]() Registered Member ![]()
|
See this page to help you porting your code:
http://eigen.tuxfamily.org/dox-devel/Ei ... igen3.html But foo.derived(i,j) never worked in eigen2 either, perhaps you meant foo.derived()(i,j). That would still work in the same way with Eigen3. And the .derived() is useless there, just do foo(i,j) where foo is the object in question.
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 ![]()
|
I had seen the page and yes I made a mistake it was obviously derived()(i,j).
I've a strange error of compilation that I don't understand : (perhapes because the beta version is beta ![]()
(In french, sorry :S) and line 117 is h.foo(x*(x.transpose())); Strange... |
![]() Registered Member ![]()
|
Yes, so the issue is that you're trying to access a single coefficient in a product expression, and we currently don't allow that because that would be inefficient. We might allow that later, but that will always be inefficient.
You should probably evaluate your product into a plain matrix, and access that.
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 ![]()
|
Ok Thanks.
It's sad that that don't work in Eigen 3 because i worked in Eigen 2. But yes it will be obviously inefficient ! However it's simple to write. |
![]() Registered Member ![]()
|
My question is probably silly but how evaluate my product into a plain matrix ?
It's strange because I can't reproduce the error but I've it in my project :S When I evaluate a product with a transposed matrix, I have this error even if I write matrix tmp = A; matrix tmp2 = A.transpose().eval(); //the eval is useless but it change nothing matrix tmp3 = tmp*tmp2; It doesn't solve the problem (but it works if I do that in a new project !) |
![]() Moderator ![]()
|
In Eigen 3 you can use A.lazyProduct(B) to have a purely lazy product expression (most of the time this is inefficient so use with caution).
To enforce evaluation to a temporary, do (A*B).eval(). Finally, when you write a template function template<typename Derived> foo(const MatrixBase<Derived>& a_mat), it is highly recommended to first copy mat to its nesting type: const typename Derived::Nesting mat(a_mat.derived()); and then use mat instead of a_mat. For a standard expression Derived::Nesting is simply Derived&, but for a matrix product it is a Matrix<...> object, and so if your function foo is called with a produc (foo(A*B)), then the product will be automatically evaluated for you... |
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]