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

sprand is type unstable #16073

Closed
KristofferC opened this issue Apr 27, 2016 · 1 comment · Fixed by #16074
Closed

sprand is type unstable #16073

KristofferC opened this issue Apr 27, 2016 · 1 comment · Fixed by #16074
Labels
sparse Sparse arrays

Comments

@KristofferC
Copy link
Member

julia> @code_warntype sprand(5,5,0.1)
Variables:
  #self#::Base.SparseArrays.#sprand
  m::Int64
  n::Int64
  density::Float64

Body:
  begin  # sparse/sparsematrix.jl, line 927:
      return (Base.SparseArrays.sprand)(Base.SparseArrays.GLOBAL_RNG,m::Int64,n::Int64,density::Float64)::Union{SparseMatrixCSC{Float64,Int64},SparseVector{Float64,Int64}}
  end::Union{SparseMatrixCSC{Float64,Int64},SparseVector{Float64,Int64}}
@tkelman tkelman added the sparse Sparse arrays label Apr 27, 2016
@KristofferC
Copy link
Member Author

KristofferC commented Apr 27, 2016

Problematic line:

N == 1 && return rand(r) <= density ? sparse(rfn(r,1)) : spzeros(T,1,1)
:

julia> sprand(Base.Random.GLOBAL_RNG,1,1,0.99,rand,Float64)
Sparse vector of length 1, with 1 Float64 nonzero entries:
  [1]  =  0.125714

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

Successfully merging a pull request may close this issue.

2 participants