Re: [eigen] QR factorization question |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] QR factorization question
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 27 Aug 2009 00:56:23 -0400
- 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=wwGY2N5tms01gZmOGyBshVPS858fuwxglJNzbXFinTM=; b=d0S0rIEbqZtEsnbv9MDqrRYF1encmZ/rWI2nMxmmShlXwQRvgwRFOZhMcABCR1HhhQ jyJFdL+llKrZm1RITkHh/9NXLoiv0yKqGItxLzzBUIqXZyGz4ilDMAmRND5MtgXXyXEg p+hHADhdqJYplYXIq1GKHzhFpKIq+7gHsevyQ=
- 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=NuIGNfiug5GmEhRuLGDwgAd4eUGkJHMPS5hxoq6skTyHVi807AJ95ZxcysOfrkbX4r Ywq6SU85cBMU5a0UB+N/l/sfHVqpYZypdY3bsOgv9e990Y7cTwdTSvxmpnmsQhJ/CKZw kQze65tRsOnPmkjZRFRnmFOgFxfy8A3hM8g+Y=
I should have said that triangularView is currently only for square
matrices. Don't call it on rectangular matrices, as it will silently
fail/crash, at the moment there isn't anything to guard that.
If you need to call triangularView on a rectangular matrix, at the
moment you need to first call block() or corner() manually, like
QR.block(0,0,n,n).triangularView....
The matrix Q is square, as it's meant to be. It's true that an
"economy size decomposition" would be nice to have, we don't offer
this at the moment. Your best approach for now is to write your own
code based on the code for matrixQ() in the file HouseholderQR.h. Feel
free to submit a patch, but before we can include that we need to
fully understand how a "economy size decomposition" works, i.e. what's
the mathematical meaning of such an economy Q, it's not fully clear in
my head at the moment.
Finally,
> is there some way to figure out what the triangularView call did (what it
> multiplied matrixQR with to make matrixQR upper triangular)
triangularView doesn't multiply anything ! it just takes a matrix and
"views" it as a triangular matrix by ignoring (regarding as 0) the
coefficients outside of the said triangle.
Benoit
2009/8/26 Eric Chu <eytchu@xxxxxxxxx>:
> great! that solved my problem.
> i have another issue though: A is a skinny matrix (m > n), and the matrix Q
> is square (m x m).
> how do i retrieve the appropriate Q matrix that goes with my (now) upper
> triangular R? (i.e. A = [Q1 Q2] [R1; 0]--or the "economy size decomposition"
> in Matlab)
> is there some way to figure out what the triangularView call did (what it
> multiplied matrixQR with to make matrixQR upper triangular) so i can apply
> it appropriately to the matrixQ and grab the first n columns.
> thanks!
> eric
> On Wed, Aug 26, 2009 at 4:41 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
> wrote:
>>
>> 2009/8/26 Eric Chu <eytchu@xxxxxxxxx>:
>> > hi all,
>> > thanks for the great work. i recently updated my version of eigen, and
>> > the
>> > api's changed a bit from before.
>> > more specifically, the qr factorization module has changed. i was
>> > wondering
>> > how i'd go about retrieving the upper triangular matrix "R" from a qr
>> > factorization.
>> > that is, if i have an m x n matrix A, and i call
>> > R = A.householderQr().matrixR();
>> > the API seems to have deprecated this function call. i think i can call
>> > matrixQR() instead, but it's no longer upper triangular. any pointers?
>>
>> Yes, matrixR() is removed at the moment, we may reintroduce it in the
>> future though once we support trapezoid matrices.
>>
>> Meawhile you can retrive R as the upper triangular part of matrixQR().
>>
>> R = A.householderQr().matrixQR().triangularView<UpperTriangular>();
>>
>> Benoit
>>
>>
>
>