Registered Member
|
Hi,
I'm porting libmv to Windows and having problems with using Eigen, would appreciate help: This is HStack() definition from libmv (horizonally stack matrices)
ROWS/COLS are macros for "Dynamic":
It works well if both arguments are Eigen::Matrix. Then they have
t is Vector3d. MS VC complains:
"libmv::Vec3" is defined as "typedef Eigen::Vector3d Vec3;" Any help would be greatly appreciated. |
Registered Member
|
Seems like I solved it myself.
Last edited by bomboze on Sun Jun 21, 2009 8:46 am, edited 1 time in total.
|
Registered Member
|
Yep, good solution You may want to make the return type Derived1 automatically determined from Derived2 and Derived3, though.
Last edited by bjacob on Sun Jun 21, 2009 1:02 pm, edited 1 time in total.
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
|
>You may want to make the return type Derived1 automatically determined from Derived2 and Derived3, though.
That's interesting. How do I do that? |
Registered Member
|
Something along these lines:
Last edited by bjacob on Mon Jun 22, 2009 12:35 am, edited 1 time in total.
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
|
Awesome! That works. Except for my typo in original code that should be: "res << lhs, rhs;" (instead of l,r) Thanks! |
Registered Member
|
Thanks once again for the solution, Benoît, I'm growing to really love Eigen.
However I've wanted to push the things a little further and stumbled into something I don't understand about Eigen's lazy evaluation. I've implemented HStack as operator| (VStack as operator&), so that I can do "(A|B)", but when I do "(A*B)|C" I get:
in here:
Not a big deal, I can do the multiplication in two steps (Matrix3f E=A*B; return E|C ), but maybe there's a better way? |
Moderator
|
this is because Options is specific to the class Matrix, so you can replace the line:
by
|
Registered Member
|
OOOPS !
There's something very bad in what i told you. Basically it only works for fixed-size matrices but not dynamic-size, because a line like
would give Dynamic+Dynamic instead of Dynamic !!! So the solution is rather:
Also in the dynamic case I think that you must set the matrix size before you use the comma initializer:
Last edited by bjacob on Mon Jun 22, 2009 2:22 pm, edited 1 time in total.
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
|
Thanks for such extensive help!
But:
|
Registered Member
|
That's just that you need to add int(...) somewhere to convert to int (which it will then be able to auto convert to the right enum type). Try around RowMajor for instance.
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
|
Options = Derived1::Flags&RowMajorBit ? (int)RowMajor : 0, error C2440: '=' : cannot convert from 'int' to '' Options = Derived1::Flags&RowMajorBit ? int(RowMajor) : 0, error C2440: '=' : cannot convert from 'int' to '' Options = Derived1::Flags&RowMajorBit ? static_cast(RowMajor) : 0, error C2440: '=' : cannot convert from 'int' to '' Options = Derived1::Flags&RowMajorBit ? RowMajor : RowMajor, // wrong, but... [!] error C2440: '=' : cannot convert from '' to '' // [!!!] (So, I guess the problem is second argument, but the error message blows my brain up from '' to '' ??) Same error: Options = int(int(Derived1::Flags&RowMajorBit) ? RowMajor : RowMajor), Options = int(Derived1::Flags&RowMajorBit) ? RowMajor : RowMajor, Options = int(Derived1::Flags&RowMajorBit ? RowMajor : 0), error C2440: '=' : cannot convert from 'int' to '' |
Registered Member
|
Oh, dam, I put Options to "typedef" instead of "enum" part. The original line works! Sorry
|
Registered Member
|
try this:
EDIT: Oh OK glad that it works
Last edited by bjacob on Mon Jun 22, 2009 4:57 pm, edited 1 time in total.
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
|
Just in case somebody else tries to replicate this function, turns out you need to also res.resize(...) before comma initialization. See here: http://codereview.appspot.com/90077/dif ... :1004/1006 lines 320 (HStack), 328 (VStack)
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]