On 8/27/07, John Randall <[EMAIL PROTECTED]> wrote:
> QR in the Essay appears to almost work on singular matrices: it looks as
> though a sign is wrong somewhere, making the orthogonality test fail.
> Here is a comparison with the results from LAPACK.
Here's a brute-force "fix" of the signs, to match LAPACK:
NB. QR from Essays
h =: +@|: NB. conjugate transpose
QR=: 3 : 0
n=.{:$A=.y
if. 1>:n do.
A (([EMAIL PROTECTED] {.@,) ; [EMAIL PROTECTED]) %:(h A) mp A
else.
m =.>.n%2
A0=.m{."1 A
A1=.m}."1 A
'Q0 R0'=.QR A0
'Q1 R1'=.QR A1 - Q0 mp T=.(h Q0) mp A1
(-Q0,.-Q1);-(R0,.T),-(-n){."1 R1
end.
)
But there's another difference -- the third column of Q from
LAPACK looks very different from the third column of Q
from QR -- LAPACK may even be noticing the singular
state of the matrix and using a different algorithm for
this case.
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm