Re: [eigen] Fast QR for 2x2, 3x3 |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Fast QR for 2x2, 3x3
- From: Andrea Arteaga <yo.eres@xxxxxxxxx>
- Date: Tue, 24 Feb 2009 23:49:34 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=RH4RRIpsRa3RzQEEYqmv3y7xiZvINX8VvjyKSIPvSe0=; b=CzRp4Sk5/nO+Ep7yyC5jxEAvGC+vglKXpTGjg1zpYhIb3qCdq7/rYGwnu4mn8Zudhj INC6yhlxY/45se8D8u7TucSE5qSVuxRlHdt3XR6QzEK/4dVknGtVP+nktMI/lCUFTNtL IZe84ErKtcqTqsadL2xVAq1zCu2AKeUGCFXtY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=RZUJyVgGFJhty+B1xWr3TuSdS99fSbH3WzF/uWowW8hbgMgYOZx5T/5aPqYM8JrF9C jAxuRfJOI+I+vHGcejo1Jy7L5wnwWOTA+ak4ydq0i9uD2VWrDgnTiXPT662uONdKKm7i 2LR1ctvQfjEZbbtNTMKU7uNH0nEIn/f+IjubU=
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.
Andrea