|
314 | 314 | Integer(value(d)) |
315 | 315 | end |
316 | 316 |
|
317 | | -for F in (:Float16, :Float32, :Float64) |
318 | | - @eval @inline Base.$F(d::Dual{T,V,N}) where {T,V,N} = convert(Dual{T,promote_type(V, $F),N}, d) |
319 | | -end |
320 | | - |
321 | 317 | @inline Random.rand(rng::AbstractRNG, d::Dual) = rand(rng, value(d)) |
322 | 318 | @inline Random.rand(::Type{Dual{T,V,N}}) where {T,V,N} = Dual{T}(rand(V), zero(Partials{N,V})) |
323 | 319 | @inline Random.rand(rng::AbstractRNG, ::Type{Dual{T,V,N}}) where {T,V,N} = Dual{T}(rand(rng, V), zero(Partials{N,V})) |
@@ -387,6 +383,10 @@ Base.convert(::Type{D}, d::D) where {D<:Dual} = d |
387 | 383 | Base.float(d::Dual{T,V,N}) where {T,V,N} = convert(Dual{T,promote_type(V, Float16),N}, d) |
388 | 384 | Base.AbstractFloat(d::Dual{T,V,N}) where {T,V,N} = convert(Dual{T,promote_type(V, Float16),N}, d) |
389 | 385 |
|
| 386 | +for F in (:Float16, :Float32, :Float64) |
| 387 | + @eval @inline Base.$F(d::Dual{T,V,N}) where {T,V,N} = convert(Dual{T,promote_type(V, $F),N}, d) |
| 388 | +end |
| 389 | + |
390 | 390 | ################################### |
391 | 391 | # General Mathematical Operations # |
392 | 392 | ################################### |
|
0 commit comments