I was puzzled by the following behaviour in Julia 0.5, which looks like a bug to me.
julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)
Platform Info:
System: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2470 v2 @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.7.1 (ORCJIT, ivybridge)
julia> speye(2)*speye(2)*speye(2)
2脳2 sparse matrix with 2 Float64 nonzero entries:
[1, 1] = 1.0
[2, 2] = 1.0
julia> speye(2)*Symmetric(speye(2))*speye(2)
2脳2 Array{Float64,2}:
1.0 0.0
0.0 1.0
julia> speye(2)*(Symmetric(speye(2))*speye(2))
2脳2 sparse matrix with 2 Float64 nonzero entries:
[1, 1] = 1.0
[2, 2] = 1.0
julia> (speye(2)*Symmetric(speye(2)))*speye(2)
2脳2 Array{Float64,2}:
1.0 0.0
0.0 1.0
I guess the shorter version is
julia> speye(2)*Symmetric(speye(2))
2脳2 Array{Float64,2}:
1.0 0.0
0.0 1.0
julia> Symmetric(speye(2))*speye(2)
2脳2 sparse matrix with 2 Float64 nonzero entries:
[1, 1] = 1.0
[2, 2] = 1.0
Most helpful comment
I guess the shorter version is