I would like to create a function in Julia that returns two matrices. One way to do that is as follows:
function AB(n,m)
A = rand(n,n)
B = rand(m,m)
return (A = A, B = B)
end
The output looks like this:
julia> AB(2,3)
(A = [0.7001462182920173 0.5485248069467998; 0.8559801029748708 0.8023848206563642], B = [0.7970654693626167 0.08666821253389378 0.45550050243098306; 0.5436826530244554 0.9204593389763813 0.9270606176586167; 0.7055633627200892 0.3702008285594489 0.670758477684624])
The output is not particularly convenient. What I would like to have is something similar to what the function qr() from LinearAlgebra returns. For example:
julia> qr(rand(3,3))
LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}}
Q factor:
3×3 LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}:
-0.789051 -0.570416 -0.228089
-0.213035 -0.0941769 0.972495
-0.576207 0.815939 -0.0472084
R factor:
3×3 Array{Float64,2}:
-0.929496 -0.563585 -0.787584
0.0 0.377304 -0.505203
0.0 0.0 -0.01765
This output is very useful to get at least some idea how these matrices look like.
How can I create a function that returns the matrices like the function qr() from LinearAlgebra?
Any help is much appreciated!