Hi Giovanni,
First of, it is great that you are using Daniel's subroutines but maybe you can try to use the LAPACK 3.4.0 ones. The subroutine name is DTPQRT.
So consider A1 of size M1-by-N with leading dimension LDA1 and A2 of size M2-by-N with leading dimension LDA2.
We also assume that
- Code: Select all
M1 >= N
(So as to be able to store a full N-by-N triangle in A1.)
First perform the QR factorization of A1 with DGEQRF. (You may also use DGEQRT or DGEQRT3 actually.)
Then perform the updating. So
- Code: Select all
DGEQRF( M1, N, A1, LDA1 ... )
DTPQRF( M2, N, 0, NB, A1, LDA1, A2, LDA2, ... )
Note: NB is the blocking size of the algorithm. We decided to have it part of the interface so you (the user) need to decide what you want NB to be.
In LAPACK, in general, NB is set by the ILAENV( ) function. So this kind of interface slightly differs from what is standard in LAPACK.
We have NB in the interface of DGEQRT and DTPQRT (both introduced in LAPACK 3.4). We also decided to export the " T matrix " to the user, see the
T, LDT arguments in the interface. This is useful for performing efficiently the updates. (This avoids to have to recompute T.)
At this point, you can (as you did with Daniel's code) check that the R factor (stored in A1 as the upper N-by-N part) matches the one of DGEQRF with [ A1 ; A2 ]
up to signs in the rows of R.
Note you can also do:
- Code: Select all
DGEQRF( M1, N, A1, LDA1 ... )
DGEQRF( M2, N, A2, LDA2 ... )
DTPQRF( N, N, N, NB, A1, LDA1, A2, LDA2, ... )
So QR factorization of A1, QR factorization of A2 and then reduce the two triangles to one.
You would get more parallelization out of this. (Less locality.)
This is the same number of operations overall.
You can also do a lots of other things. I let you imagine.
Can anyone please advice how to update QR from Daniel's output? given that the old QR is in compact LAPACK form as result of calling DGEQRF, meaning the upper triangle contains R and the lower triangle a normalized set of reflectors and tau. I can call Daniel's routine fine and I get the B replaced with column reflectors Hnew_1 ... Hnew_n ... and get the tau_new.
( All your wrote makes sense. )
My problem is how to _merge_ these new smaller reflectors with the existing ones Hold_1 ... Hold_n and tau_old in a way I can put them all as one back in compact form as if it was output by DGEQRF.
The answer is that with Daniel's subroutines or LAPACK-3.4, you cannot compute back the exact same reflectors as DGEQRF would do.
The main point is that there is not much point in computing these reflectors. What you want to do is being able to apply them to another
matrix (and this is done easily by DORMQRT and DTPMQRT) or you want to compute Q (and this is done as well by applying the reflectors
with DTPMQRT to the identity matrix.)
I hope this makes sense. If not we can give a sample example.
Cheers,
Julien.