[Marble-devel] Eigen

Torsten Rahn rahn at kde.org
Fri Jan 16 10:03:38 CET 2009


Hi Benoit,

On Wednesday 14 January 2009 01:13:35 Benoit Jacob wrote:
> void Quaternion::normalize()
> if you used eigen you could do v.squaredNorm() and enjoy SSE or
> AltiVec vectorization!
>     scalar( 1.0 / sqrt(quatNorm) );
> same remark (vectorization).

These two methods don't resemble a bottleneck in Marble at all (and it's 
unlikely that they ever will).  So vectorization of these isn't that much of a 
teaser ;-)

> void Quaternion::scalar(qreal mult)
> same remark (vectorization) plus, the naming of this method feels
> strange, did you mean scale() ?

No. "scalar" as in "scalar multiplication" which is the common term for this 
kind of multiplication (as opposed to an inner product).  However thinking 
about it I realize that this method name could get mistaken for "scalar 
product" which _is_ an inner product and which must not be mixed up with 
"scalar multiplication". 
So I agree that "scale" would probably be indeed a better choice. 

> Your operator== doesn't work, basically it will very often return
> false when it should return true, for floating point you really need
> fuzzy compares. Eigen offers a isApprox() method also in Quaternion.

You are right about this one. Although it would work when comparing two 
quaternions that share the same 4 components it could very well be that two 
quaternions resemble the same operation but use a different component 
representation. 
This hasn't been an issue in Marble so far however.

> Quaternion Quaternion::operator*(const Quaternion &q) const
> same for us: we also haven't vectorized that as that would be a bit of
> work.

I'd be more interested in vectorization of 

    void        Quaternion::rotateAroundAxis(const matrix &m);

As that is the one we are using at the moment. However again as an initial 
step I'd rather prefer copying over code if possible. Once we'd use a lot more 
code of Eigen of course it would become tempting to use the library directly 
instead. But I don't see that happen near-term.

> the work once and running on both SSE + AltiVec (+ any future
> platform).

Yes, that is one of the parts of Eigen that are interesting to me. However 
given that this very interest currently covers only a _single_ method I'm 
looking for different options than linking against the whole library.

Best Regards,

Torsten




More information about the Marble-devel mailing list