Registered Member
|
Hi Eigen users,
I am starting to get familiar with Eigen and I now use it in my research for many calculations. It is an awesome tool. Many thanks to all the developers! I am starting to write template classes (simple functors) that work with Eigen types. By using MatrixBase<Derived> as template parameters, as suggested by the documentation, I was able to successfully specialise the class for plain matrices and the Block type, but I had no luck with the VectorBlock type. I cannot seem to find the right expression! I have no problem with template functions that are implicitly specialised. Here is a trivial example illustrating this:
I use Eigen 3.0 beta 2 and GCC 4.4.4 on Ubuntu. (I also tried on other Linux variants and with other GCC versions.) Thanks in advance to anyone who can help! Olivier |
Moderator
|
the VectorBlock<> template class is just a convenient class to declare and construct vector block expressions, but it is essentially a Block<>, so in your case you should do:
g_func< Block<VectorXd> > g3(v.segment(0, 5)); |
Registered Member
|
Thanks for the suggestion. I tried it before, but it does not work. I get:
|
Moderator
|
oops sorry, it is:
g_func< Block<VectorXd,Dynamic,1> > g3(v.segment(0, 5)); Another solution is to take: g_func< VectorBlock<VectorXd>::Derived > g3(v.segment(0, 5)); I agree that's not obvious. |
Registered Member
|
Thank you!
I will make note of all my related beginner difficulties and then write a patch for the documentation. |
Registered Member
|
I would note that interfacing directly with our expression templates is NOT a "beginner" issue!
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft