Implementation
This leads us to a way to solve our linear system, we just use our previous methods to solve the normal equations as a n×n system. Since ATA is symmetric and positive definite, we can use the Cholesky (N=RTR) factorization:
function lsnormal(A,b)
N = A'*A; z = A'*b;
R = cholesky(N).U
w = FNC.forwardsub(R',z) # solve R'z=c
x = FNC.backsub(R,w) # solve Rx=z
return x
end
This takes ∼(mn2+13n3) flops