Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with similar for reshaped sparse matrix #430

Closed
jebej opened this issue May 21, 2017 · 2 comments
Closed

Issue with similar for reshaped sparse matrix #430

jebej opened this issue May 21, 2017 · 2 comments
Labels
sparse Sparse arrays

Comments

@jebej
Copy link
Contributor

jebej commented May 21, 2017

Currently this does not work due to a missing spzeros method:

rdims = (2,2)
perm = [2,4,1,3]
A = sparse([1,4,2,3,2,3,1,4],[1,1,2,2,3,3,4,4],[0.125,0.125,0.375,0.375,0.375,0.375,0.125,0.125])
B = reshape(A,rdims...,rdims...)
C = permutedims(B,perm)
ERROR: MethodError: no method matching spzeros(::Type{Float64}, ::Int64, ::Int64, ::Int64, ::Int64)
Closest candidates are:
  spzeros(::Type, ::Integer, ::Integer) at sparse\sparsematrix.jl:1372
  spzeros(::Type, ::Type, ::Integer, ::Integer) at sparse\sparsematrix.jl:1374
  spzeros(::Type{T}, ::Integer) where T at sparse\sparsevector.jl:47
  ...
Stacktrace:
 [1] similar(::Base.ReshapedArray{Float64,4,SparseMatrixCSC{Float64,Int64},Tuple{Base.MultiplicativeInverses.S
ignedMultiplicativeInverse{Int64}}}, ::NTuple{4,Base.OneTo{Int64}}) at .\abstractarray.jl:514
 [2] permutedims(::Base.ReshapedArray{Float64,4,SparseMatrixCSC{Float64,Int64},Tuple{Base.MultiplicativeInvers
es.SignedMultiplicativeInverse{Int64}}}, ::Array{Int64,1}) at .\permuteddimsarray.jl:115

Just trying to copy(B) also fails for the same reason.

It seems like it should work, since the following does work:

C = reshape(copy(A),rdims...,rdims...)
permutedims!(C,B,perm)
@marekdedic
Copy link

I think this is caused by JuliaLang/julia#23905.

@Sacha0
Copy link
Member

Sacha0 commented Oct 24, 2017

Fixed by JuliaLang/julia#17507 and JuliaLang/julia#24260 on master. Thanks!

@Sacha0 Sacha0 closed this as completed Oct 24, 2017
@KristofferC KristofferC transferred this issue from JuliaLang/julia Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparse Sparse arrays
Projects
None yet
Development

No branches or pull requests

4 participants