I have been working on implementing in C some of the LAPACK algorithms and occasionally verifying output from my version to corresponding LAPACK functions. Some time ago I had problems with generating the Q matrix from RQ factorization. Whenever I set value of K less than M the outputs were different. Suspect was my code but I could not any obvious bug. When I commputed identity ||I - Q*Q.T|| which should be close to zero, I noticed that the identity did not hold with matrix generated with dorgr2 when K != M.
Looking at the code of DORGR2 it seems that indexing of the elementary vector is not in sync with indexing of the tau coefficent. In the code below it should read 'tau(ii)' instead of 'tau(i)'
- Code: Select all
DO 40 i = 1, k
ii = m - k + i
* Apply H(i) to A(1:m-k+i,1:n-k+i) from the right
*
a( ii, n-m+ii ) = one
CALL dlarf( 'Right', ii-1, n-m+ii, a( ii, 1 ), lda, tau( i ),
$ a, lda, work )
CALL dscal( n-m+ii-1, -tau( i ), a( ii, 1 ), lda )
a( ii, n-m+ii ) = one - tau( i )
*
* Set A(m-k+i,n-k+i+1:n) to zero
*
DO 30 l = n - m + ii + 1, n
a( ii, l ) = zero
30 CONTINUE
40 CONTINUE
regards,
Harri
P.S. For the curious my code is available in https://github.com/hrautila/armas

