Merge pull request #546 from ChrisRackauckas/random
Support random numbers as constants
This commit is contained in:
commit
827a7b8ed5
@ -59,6 +59,12 @@ Base.float(x::TrackedReal) = x
|
|||||||
Base.promote_rule(::Type{TrackedReal{S}},::Type{T}) where {S,T} =
|
Base.promote_rule(::Type{TrackedReal{S}},::Type{T}) where {S,T} =
|
||||||
TrackedReal{promote_type(S,T)}
|
TrackedReal{promote_type(S,T)}
|
||||||
|
|
||||||
|
using Random
|
||||||
|
|
||||||
|
for f in :[rand, randn, randexp].args
|
||||||
|
@eval Random.$f(rng::AbstractRNG,::Type{TrackedReal{T}}) where {T} = param(rand(rng,T))
|
||||||
|
end
|
||||||
|
|
||||||
using DiffRules, SpecialFunctions, NaNMath
|
using DiffRules, SpecialFunctions, NaNMath
|
||||||
|
|
||||||
for (M, f, arity) in DiffRules.diffrules()
|
for (M, f, arity) in DiffRules.diffrules()
|
||||||
|
Loading…
Reference in New Issue
Block a user