[eigen] Specialized QR

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


I did some work on QR module to do some specialized version for small matrices.
My idea is to introduce a class qr_compute, which does all the work (QR decomposition, matrixQ, matrixR, rank, solve,...) whit respect to the choosen algorithm (Householder, Gram-Schmidt or Givens). The QR class were only a front-end to this class. In this way, we don't need to specialize the QR, but only the backend qr_compute class.


The logic to decide which algorithm to use were done by a qr_decide class in this way:


template<int rows, int cols> struct qr_decide {
enum { Algorithm = rows < 3 ? 1 : ((rows < 15 && cols < 15) ? 2 : 3) };
};


Number 1 is Givens (for matrices with only 2 rows), 2 Gram-Schmidt (3x2 upper to 15x15), 3 Householder.


The QR class should have a private member, e.g.:


qr_compute<MatrixType, qr_decide<MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime>::Algorithm > compute_;


The QR constructor should simply call the method compute() of member compute_ to delegate all the work to this specialized class.


Other public members of QR, which delagate work to qr_compute should be:
  • matrixQ()
  • matrixR()
  • rank()
  • solve()

The others public members (i.e.: dimensioOfKernel(), isInjective(), isSurjective(), isInvertible()) don't need to use the compute_ member.

If you mean that this work is useful, I can begin to code the three specialized versions of qr_compute, i.e.: write a simply (hard-coded) givens rotation for 2x* matrices, re-code the householder orthogonalization by move the code from QR to qr_compute and write a Gram-Schmidt orthogonalization.



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