From f0080a0cad75592563fbad87dedd19f43f1e5b74 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Wed, 27 Apr 2016 15:59:23 +0200 Subject: [PATCH] fix use of undefined variable in sprand --- base/sparse/sparsematrix.jl | 2 +- test/sparsedir/sparse.jl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index fb3d3aa74edee1..183c4f4bad9e6a 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -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 diff --git a/test/sparsedir/sparse.jl b/test/sparsedir/sparse.jl index 174c13a43ede5d..bc847dcaaa897c 100644 --- a/test/sparsedir/sparse.jl +++ b/test/sparsedir/sparse.jl @@ -1322,3 +1322,4 @@ end # 16073 @inferred sprand(1, 1, 1.0) +@inferred sprand(1, 1, 1.0, rand, Float64) \ No newline at end of file