Re: [eigen] Optimization advice for a specific expression

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On 2016-02-04 17:02, Alberto Luaces wrote:
Other than that: * What exactly do you mean by homogeneous?

G = [ v3x3 | 0]
     [  0ᵀ  | 1]

where "v3x3" is a 3x3 matrix, and "0" a vector of 3 zero-valued elements.

Can you make any assumptions on the determinant of G? (Calculating the
det didn't not seem to be the bottleneck, though)

No, I cannot, but as you point, removing the determinant computation for
testing purposes does not yield any improvement.

Given the above, you have:
  G.determinant() == v3x3.determinant(),
which should be significantly faster than the full determinant.
If v3x3 happens to be a rotation matrix, G.determinant()==1;

Does it have any special form (e.g. low rank, or Identity+lowRank)

It is just symmetric:

Eplus << 2 , 1 , 1 , 5,
          1 , 2 , 1 , 5,
          1 , 1 , 2 , 5,
          5 , 5 , 5 , 20;

The upper left is Identity + [1,1,1]^T*[1,1,1]. I'll abbreviate V=v3x3.
If you then define w=V*[1,1,1]^T == V.rowwise().sum(), the resulting summand is (without the determinant factor):
  [ V*V^T + w*w^T,  5*w ]
  [ 5*w^T        ,  20  ]

Again, if V happens to be a rotation, then V*V^T=Identity

So with a bit of hand-coding you may gain a lot efficiency here. It may be tricky to get it right that vectorization can still be used. E.g., instead of V.rowwise().sum() you can calculate Vector4d w=G.leftCols<3>().rowwise().sum(), which should be near optimal [again, check the generated assembly] Multiplication by 5 can be done at the end (if I4x4 initially is 0), and the lower right element is just 20*{sum of determinants}.

Cheers,
Christoph



--
 Dipl. Inf., Dipl. Math. Christoph Hertzberg

 Universität Bremen
 FB 3 - Mathematik und Informatik
 AG Robotik
 Robert-Hooke-Straße 1
 28359 Bremen, Germany

 Zentrale: +49 421 178 45-6611

 Besuchsadresse der Nebengeschäftsstelle:
 Robert-Hooke-Straße 5
 28359 Bremen, Germany

 Tel.:    +49 421 178 45-4021
 Empfang: +49 421 178 45-6600
 Fax:     +49 421 178 45-4150
 E-Mail:  chtz@xxxxxxxxxxxxxxxxxxxxxxxx

 Weitere Informationen: http://www.informatik.uni-bremen.de/robotik



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/