Open
Description
Consider the following code
using LinearAlgebra, StaticArrays
a = [0.8045637657777136 -0.5871860208192704; -0.5920697370223342 -0.7814816517349663; 0.046158133626574324 0.21094787260368533 ]
p = SMatrix{3,2}(a...)
b = [0.0902581948780876 0.971125474230239; 0.7756374067122164 -0.2076324892367811; 0.971125474230239 0.1174906920331621 ]
q = SMatrix{3,2}(b...)
M = p' * q
QR = qr(q - p * M)
V = convert(Matrix, qr([M; QR.R]).Q * I) # should be 4x4 is 4x2
M2 = a' * b
QR2 = qr(a - b * M2)
V2 = convert(Matrix, qr([M2; QR2.R]).Q * I) # correct form
Note especially that the inner qr
has two different types
julia> qr([M; QR.R]).Q
4×2 SMatrix{4, 2, Float64, 8} with indices SOneTo(4)×SOneTo(2):
-0.274279 0.919138
-0.364558 -0.371476
-0.88987 -0.131115
0.0 -3.54073e-16
julia> qr([M2; QR2.R]).Q
4×4 LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}}:
-0.224564 0.45094 -0.708849 -0.493718
-0.29848 -0.206537 -0.557078 0.746938
-0.927621 -0.0427088 0.350853 -0.120819
0.0 0.867278 0.253177 0.428637
So how can I get the full form for both in a unified form?