Given a full matrix A
and a sparse matrix B
, matrix multiplication gives a different resulting type (either full or sparse) depending on the order of multiplication and whether or not a transpose is involved:
julia> A = randn(5,5);
julia> B = sprand(5,5,.1);
julia> typeof(A*B)
Array{Float64,2}
julia> typeof(B*A)
Array{Float64,2}
julia> typeof(A'*B)
SparseMatrixCSC{Float64,Int64}
julia> typeof(A*B')
SparseMatrixCSC{Float64,Int64}
julia> typeof(B*A')
Array{Float64,2}
julia> typeof(B'*A)
Array{Float64,2}
What is the logic behind these resulting types?