[eigen] request for help: 4x4 matrix inverse

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


Hi List,

I have started coding the LU module and committed already this:
- optimized determinants for sizes <=4
  (Thanks to Geoff for pointing me to the 30-mul technique for size 4).
- general matrix inversion (good for sizes >= 5)
- bruteforce matrix inversion using cofactors for sizes <=3
- unrolled version of the general method for size 4

Since the latter unrolled version is clumsy and is only used for size 4, since 
after all it seems that a bruteforce (cofactor) technique would be faster, 
and since size 4 is a common case that we want to optimize, I am asking:

do you have good 4x4 matrix inversion code that you could contribute? Or can 
you point me to a good "algorithm" ? I put quotation marks because we know 
the algorithm is just brutefore, the question is how to implement it to 
minimize the number of ops and perhaps to take advantage of vectorization...

Markos: if I remember correctly, you mentioned you had AltiVec code for that. 
When you mentioned it I was still hoping that the unrolled gaussian 
elimination would be good but now I realize that it's not, so I'm very much 
interested in your code if you want to contribute it :) Extra points if it 
also works with SSE.

I am also -- and most importantly -- looking for an optimized non-vectorized 
path!

As you'll see in src/LU/Inverse.h, we have a template parameter bool 
CheckExistence. If true, we must carefully check that the inverse exists. 
Ideally, your implementation would do that in an optimized way when 
CheckExistence==true, and we would not pay any cost when 
CheckExistence==false.

The API is:

Matrix4d m;
m.inverse(); // CheckExistence==true
m.quickInverse(); // CheckExistence==false

Inverse<Matrix4d> inverse_of_m(m);
  // or, if you prefer, Inverse<Matrix4d> inverse_of_m = m.inverse();
if(inverse_of_m.exists())
{
	cout << inverse_of_m << endl;
}

Cheers,

Benoit

Attachment: signature.asc
Description: This is a digitally signed message part.



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