If you orthogonalize with classical Gram-Schmidt twice you’ll be fine. The GMRES code in ```SIAMFANLEquations.jl```` does it that way. That code, and the orthogonalizer live in
https://github.com/ctkelley/SIAMFANLEquations.jl/tree/master/src/Solvers/LinearSolvers
Here is a quick and dirty qr code that uses the orthogonalizer and overwrites A
with Q.
The default option, cgs2
is classical Gram-Schmidt twice, which is the best choice on any modern computer.
function qrctk!(A, orth = "cgs2")
T = typeof(A[1, 1])
(m, n) = size(A)
R = zeros(T, n, n)
@views R[1, 1] = norm(A[:, 1])
@views A[:, 1] /= R[1, 1]
@views for k = 2:n
hv = vec(R[1:k, k])
Qkm = view(A, :, 1:k-1)
vv = vec(A[:, k])
Orthogonalize!(Qkm, hv, vv, orth)
end
return (Q = A, R = R)
end