@@ -69,13 +69,13 @@ spzeros(dims::Dims) = spzeros(Float64, dims)
6969spzeros (:: Type{T} , dims:: Dims ) where {T} = SparseArrayDOK {T} (undef, dims)
7070
7171@doc """
72- sprand([rng], [T::Type], dims; density::Real=0.5, rand_function ::Function=rand) -> A::SparseArrayDOK{T}
72+ sprand([rng], [T::Type], dims; density::Real=0.5, randfun ::Function=rand) -> A::SparseArrayDOK{T}
7373
7474Create a random size `dims` sparse array in which the probability of any element being stored is independently given by `density`.
7575The optional `rng` argument specifies a random number generator, see also `Random`.
7676The optional `T` argument specifies the element type, which defaults to `Float64`.
77- The optional `rand_function ` argument can be used to control the type of random elements, and should support
78- the signature `rand_function (rng, T, N)` to generate `N` entries of type `T`.
77+ The optional `randfun ` argument can be used to control the type of random elements, and should support
78+ the signature `randfun (rng, T, N)` to generate `N` entries of type `T`.
7979
8080
8181See also [`sprand!`](@ref).
@@ -95,24 +95,24 @@ function sprand(rng::AbstractRNG, ::Type{T}, dims::Dims; kwargs...) where {T}
9595end
9696
9797@doc """
98- sprand!([rng], A::AbstractArray; density::Real=0.5, rand_function ::Function=rand) -> A
98+ sprand!([rng], A::AbstractArray; density::Real=0.5, randfun ::Function=rand) -> A
9999
100100Overwrite part of an array with random entries, where the probability of overwriting is independently given by `density`.
101101The optional `rng` argument specifies a random number generator, see also `Random`.
102- The optional `rand_function ` argument can be used to control the type of random elements, and should support
103- the signature `rand_function (rng, T, N)` to generate `N` entries of type `T`.
102+ The optional `randfun ` argument can be used to control the type of random elements, and should support
103+ the signature `randfun (rng, T, N)` to generate `N` entries of type `T`.
104104
105105See also [`sprand`](@ref).
106106""" sprand!
107107
108108sprand! (A:: AbstractArray ; kwargs... ) = sprand! (default_rng (), A; kwargs... )
109109function sprand! (
110- rng:: AbstractRNG , A:: AbstractArray ; density:: Real = 0.5 , rand_function :: Function = Random. rand
110+ rng:: AbstractRNG , A:: AbstractArray ; density:: Real = 0.5 , randfun :: Function = Random. rand
111111)
112112 ArrayLayouts. zero! (A)
113113 rand_inds = Random. randsubseq (rng, eachindex (A), density)
114- rand_entries = rand_function (rng, eltype (A), length (rand_inds))
115- for (I, v) in zip (rand_inds, rand_entries)
114+ rand_entries = randfun (rng, eltype (A), length (rand_inds))
115+ @inbounds for (I, v) in zip (rand_inds, rand_entries)
116116 A[I] = v
117117 end
118118end
0 commit comments