Skip to content

Commit

Permalink
fix use of undefined variable in sprand
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Apr 27, 2016
1 parent 2ba30c2 commit f0080a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ function sprand{T}(m::Integer, n::Integer, density::AbstractFloat,
rfn::Function, ::Type{T}=eltype(rfn(1)))
N = m*n
N == 0 && return spzeros(T,m,n)
N == 1 && return rand() <= density ? sparse([1], [1], rfn(r,1)) : spzeros(T,1,1)
N == 1 && return rand() <= density ? sparse([1], [1], rfn(GLOBAL_RNG,1)) : spzeros(T,1,1)

I,J = sprand_IJ(GLOBAL_RNG, m, n, density)
sparse_IJ_sorted!(I, J, rfn(length(I)), m, n, +) # it will never need to combine
Expand Down
1 change: 1 addition & 0 deletions test/sparsedir/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1322,3 +1322,4 @@ end

# 16073
@inferred sprand(1, 1, 1.0)
@inferred sprand(1, 1, 1.0, rand, Float64)

0 comments on commit f0080a0

Please sign in to comment.