[Marble-devel] Eigen

Benoit Jacob jacob.benoit.1 at gmail.com
Fri Jan 16 13:23:46 CET 2009


2009/1/16 Torsten Rahn <rahn at kde.org>:
>> 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.

ok sorry to bikeshed about the naming of your own internal stuff :)
my concern was that "a scalar" means "a number" so a method named
scalar(...) would be expected to return a scalar, not void.

>> 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.

No, my concern was different. Suppose that you have two quaternions q1, q2.
Do:
q3 = q1*q2;
q4 = q3/q2;
Now one would expect q4 to be the same as q1, but because of the
finite precision of qreal they can actually be slightly different.

To give a more reproducible / general example:
__attribute__((noinline)) void foo(double x) { std::cout << 1. - 7.*x
<< std::endl; }
double x = 1./7.;
foo(x);
This _should_ print 0 but will actually print something like 1e-16.
Unless your compiler inlined foo and was very clever (gcc 4.3 is)

>> 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.

ok against you don't _link_ against Eigen, it's templates.

Cheers,
Benoit


More information about the Marble-devel mailing list