Re: [eigen] geometry module |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] geometry module
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 8 Sep 2010 12:54:52 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=7gaRpHpT8toC3/LgT8QkkQ1/pg4PKq3IHpUVWEwNGHg=; b=NCQ68gb0t1HiOlDiim/JjFpjvmTTfXF8FH8Ki9kiuaCd5VosFqVLgH2yZF9NhZEw9j R7LQz5T4jy0KQbte+MgZT5j7L1swQzp+v3xkv/OSqVQmMBtt0sDJIglKLo7lSf/dTta+ xLnQNBgBslBKNa1iQICgUar+D4/T43CbzC/Jg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=KXEgFlNBoxoqvs+cRQtTZD1AouggyT2ziGaIfKEyLoxeLirncmaoTzI679lubAP5IW 1hDfWa/nsMZQubvLNTWdMBgHzX1nRN3sLbMxiHkUmrjI+3euN6LfCWbEz/1bTyBHZ4M+ Hr4Rif+DjTux9Fab48CwNDCmqWebAyNzIdoRw=
On Tue, Sep 7, 2010 at 12:57 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> Here, "most efficiently" depends on what you're doing. If you want to
> apply this transformation to a vector, it's going to be faster if you
> have a matrix representation of your transform, as the Transform class
> does. This is one of the most performance-critical use cases...
some numbers to transform N 3D vectors stored into a 3xN column major
matrix and transformed using a 3x3 matrix, a quaternion using the
quaternion x a single vector product, and a quaternion converted on
the fly to a 3x3 matrix. The times are in second for 100000 runs (in
the last case the quaternion is converted 100000 times to a matrix).
N 1 2 3 4 5 6
7 8
matrix 3x3 0.0007521 0.0008807 0.001357 0.002339 0.002869 0.003583
0.004301 0.02684
quaternion 0.001332 0.002183 0.003098 0.004002 0.004913 0.005945
0.007081 0.007997
quat-mat 0.001165 0.00152 0.001822 0.002925 0.003396 0.003964
0.004615 0.02727
as expected the matrix product is significantly faster, but what is
surprising is that even for transforming a single vector (N=1), it is
faster to convert the quaternion to a matrix and then perform the
matrix product rather than directly using the optimized
quaternion-vector product since the costs are respectively:
3x3 matrix : 9 mul + 6 add = 15 ops
quaternion : 15 mul + 15 add = 30 ops
quat-mat : 18 mul + 21 add = 39 ops
These numbers directly come from the assembly where we can see gcc
optimized the "2 * v" by "v+v".
also Daniel you might be interested to know that this benchmark is in
bench/quaternion.cpp (in trunk).
gael