Q factor changes size(?) in qr() in 0.7.0-beta2


#1

In the following example from 0.7.0beta2, the Q factor appears to be 3-by-3, but then somehow it becomes 3-by-2 when I copy it out. Can anyone explain this behavior? It does not seem to be documented. EDIT: I forgot to include in my original post the definition of A; it is: A=randn(3,2).

julia> F = qr(A)
WARNING: Base.qr is deprecated: it has been moved to the standard library package `LinearAlgebra`.
Add `using LinearAlgebra` to your imports.
 in module Main
LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}}
Q factor:
3×3 LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}:
 -0.854699   0.432186   0.287585
 -0.392329  -0.900543   0.187348
  0.339952   0.0472983  0.939253
R factor:
2×2 Array{Float64,2}:
 1.51634   0.750205
 0.0      -1.40104

julia> F.Q
3×3 LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}:
 -0.854699   0.432186   0.287585
 -0.392329  -0.900543   0.187348
  0.339952   0.0472983  0.939253

julia> Matrix(F.Q)
3×2 Array{Float64,2}:
 -0.854699   0.432186
 -0.392329  -0.900543
  0.339952   0.0472983

#2

I just found that QR has lost of a feature compared to 0.6. In 0.6, an m-by-n matrix with n=0 is fine:

julia> Q,R = qr(zeros(4,0))
(Array{Float64}(4,0), Array{Float64}(0,0))

but not in 0.7 (see below). Should I open an issue about these two problems with qr?

julia> F = qr(zeros(4,0))
LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}}
Q factor:
4×4 LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}:
 1.0  0.0  0.0  0.0
 0.0  1.0  0.0  0.0
 0.0  0.0  1.0  0.0
 0.0  0.0  0.0  1.0
R factor:
Error showing value of type LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}}:
ERROR: ArgumentError: the requested diagonal, 0, must be at least 1 and at most 1 in an 0-by-0 matrix
Stacktrace:
 [1] triu!(::Array{Float64,2}, ::Int64) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\LinearAlgebra\src\dense.jl:175
 [2] triu! at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\LinearAlgebra\src\generic.jl:237 [inlined]
 [3] getproperty at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\LinearAlgebra\src\qr.jl:419 [inlined]
 [4] show(::IOContext{REPL.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}}) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\LinearAlgebra\src\qr.jl:399
 [5] display(::REPL.REPLDisplay{REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}}) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:130
 [6] display(::REPL.REPLDisplay{REPL.LineEditREPL}, ::LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}}) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:133
 [7] display(::LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}}) at .\multimedia.jl:287
 [8] #invokelatest#1 at .\essentials.jl:660 [inlined]
 [9] invokelatest at .\essentials.jl:659 [inlined]
 [10] print_response(::REPL.Terminals.TTYTerminal, ::Any, ::Nothing, ::Bool, ::Bool, ::Nothing) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:151
 [11] print_response(::REPL.LineEditREPL, ::Any, ::Nothing, ::Bool, ::Bool) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:137
 [12] (::getfield(REPL, Symbol("#do_respond#42")){Bool,getfield(REPL, Symbol("##52#61")){REPL.LineEditREPL,REPL.REPLHistoryProvider},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::Base.GenericIOBuffer{Array{UInt8,1}}, ::Bool) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:706
 [13] top-level scope at none:0

#3

See https://github.com/JuliaLang/julia/issues/27397