User talk:Petelomax: Difference between revisions

Line 90:
Hi Pete. In the Phix code for QR decomposition I spotted a minor typo when translating to VBA. When you copy a into R i is taken from 1 to n in stead of m. For a non square matrix the Phix solution won't work. [[User:Dedalus|Dedalus]] ([[User talk:Dedalus|talk]]) 11:03, 15 March 2019 (UTC)
:Thanks, but m>=n, so changing it would only ever result in (m-n) null j-loops. I can see why you needed it for VBA though. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 12:22, 15 March 2019 (UTC)
:Oh, be warned the distribution copy contains this:
<lang Phix>--
-- Programming note: The code of this main loop was not as easily
-- written as the first glance might suggest. Explicitly setting
-- to 0 any a[i,j] [etc] that should be 0 but have inadvertently
-- gotten set to +/-1e-15 or thereabouts may be advisable. The
-- commented-out code was retrieved from a backup and should be
-- treated as an example and not be trusted (iirc, it made no
-- difference to the test cases used, so I deleted it, and then
-- had second thoughts a few days later).
--
for j=1 to min(m-1,n) do
u = mat_col(a,j)
u[j] -= mat_norm(u)
v = sq_div(u,mat_norm(u))
q = sq_sub(I,sq_mul(2,matrix_mul(vtranspose(v),{v})))
a = matrix_mul(q,a)
-- for row=j+1 to length(a) do
-- a[row][j] = 0
-- end for
Q = matrix_mul(Q,q)
end for</lang>
7,806

edits