Talk:QR decomposition: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 14:
The reason seems to be that the loop which creates the Householder matrices loops over the number of rows in the input matrix m (m->m), and attempts to extract a column with the same index as the row index from the matrix z (which has the same dimensions as m). This is fine if m->m <= m->n. For purposes of solving over-determined equation systems, however, we will have m->m > m->n. Consequently, we will try to extract non-existing columns from the matrix z, and what they contain will be indeterminate. Should it happen that all column elements are zero, the division by zero referred to above will take place. This of course renders the whole calculation useless. --[[User:Ernstegon|Ernstegon]] 21:22, 17 November 2012 (UTC)
:: You are right, the code was using the wrong subscript of the matrices. Goes to show that ugly code is more prone to bugs. I hope it's fixed now. --[[User:Ledrug|Ledrug]] 07:33, 19 November 2012 (UTC)
:::Thanks for looking at the problem so quickly. However, I still have doubts. Is the result really a correct QR decomposition? Is not the matrix R supposed to be upper triangular, i.e. all elements below the diagonal should be zero? That is not the case with the results produced with the amended code. When I use it for solving an over-determined system of linear equations, I get results that differ by quite a bit from Matlab - more than could ever be explained by numerical issues. I tried the following simple system in Matlab:<br>
:::A = [1.0 -2.0; 1.0 -1.0; 1.0 0.0; 1.0 2.0; 1.0 3.0]<br>
:::B = [-4.0 -1.0 3.0 6.0 13.0]'<br>
:::X = A\B<br>
:::The result is X = [2.162790698 3.093023256]<br>
:::When I try the amended code in a C test program, using the same input data, I get X = [2.156692 3.108271]. Close, but no cigar.<br>
:::The code as it was before your update produced X = [2.162790 3.093023] - in those cases where it did not crash. --[[User:Ernstegon|Ernstegon]] 16:14, 19 November 2012 (UTC)
 
 
Anonymous user