Re: [eigen] Eigen and rigid body simulation |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
Say i have a Quaternion, q, and i want to fastExp it. Then I have to do:
Quaternion res = fastExp( q, n ).get();
It seems there are two Quaternion copies here: one when constructing the
LieGroup<Quaternion>, and one when affecting the wrapped quaternion to the
result. I was worried about the first one: is the compiler clever enough to
elide it ?
In fact, I tend to only use the LieGroup<Quaternion> when working on Lie
groups. But to answer your question, the second copy is elided and the
first one can be avoided, using:
Quaternion res = fastExp( Lie<Map<Quaternion<...> >(q), n ).get();
Making all this benefit from expression templates would be painful, and i'm
not really conviced this would bring much performance enhancement: the
operations are sometimes complicated and the temporaries are small anyway, in
most cases.
For example when you multiply 3 matrices together, you probably still need a
temporary at some point to cache results, otherwise the complexity explodes.
Most Lie group operations are of that kind, unless you're considering additive
vector/matrix groups.
Yes, I agree.
But if we were to do it anyway, we would have to implement Lie group
expression templates for each type in the geometry module, then use trait
classes to determine return types in the wrapper...
Indeed, more work than implementing the wrapper and based functions.
Or we could enable -std=c++0x in gcc and use the almighty "auto" keyword ;-)
in a few years with other compiler too, hopefully :)
If I sum things up so far:
* Your wrapper has a member value
* The user sees the wrapper
* Group specific-code is implemented in separate struct, in static functions
(the ei_lie_composition )
* My wrapper captures by reference (possibly lvalues)
* Only the developper sees the wrapper
* Group specific-code is implemented in a separate struct, in static functions
( the concept map )
So apart from syntax considerations, the only difference is how does the
wrapper wrap, with (minor) perfomance implications.
That's right.
I think we're getting slightly picky :)
I know, but if we want other peoples, who are not used to Lie Group or
even group formulation to used this code, I think we have to simplify
the syntax.
--
Mathieu Gautier