Re: [eigen] Fast QR for 2x2, 3x3

[ Thread Index | Date Index | More Archives ]

I thought about how to include the code in th QR.h header. I think that the fastest way is to specialize the MatrixBase<Derived>::qr() method such that for small matrices it calls one cunstructor of the QR class, for each other matrices it calls another constructor. The two constructors can be differentiated by add an argument enum qr_algorithm with default value Householder in this way:

enum qr_algorithm { Householder, Givens, GramSchmidt }; 
QR(const MatrixType& matrix, qr_algorithm alg = Householder)
Old code is also compatible thanks to default value. The constructor will also control if alg is Householder (and then execute the normal _compute() method) o Givens (or GramSchmidt) and then execute another method (for example _compute_givens() ), which does the same using Givens - and the Markus' code.
If this run-time control is too inefficient, we can implement a compile-time control (with templates), but that cannot perhaps ensure the backward-compatibility of the code.
Note that all this only works with fixed-size matrices. For dynamically-sized matriced we need a run-time implementation without specialization of the MatrixBase::qr() method.

Mail converted by MHonArc 2.6.19+