Julia: Unexpected conversion from sparse to dense

Created on 18 Apr 2017  路  1Comment  路  Source: JuliaLang/julia

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

linear algebra sparse

Most helpful comment

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

>All comments

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
Was this page helpful?
0 / 5 - 0 ratings

Related issues

m-j-w picture m-j-w  路  3Comments

omus picture omus  路  3Comments

TotalVerb picture TotalVerb  路  3Comments

musm picture musm  路  3Comments

Keno picture Keno  路  3Comments