Skip to content

Commit 05729ff

Browse files
committed
simplify y
1 parent 345b97e commit 05729ff

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/dual.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -772,13 +772,12 @@ end
772772
# creates the copy of x and applies fvalue!(values) to its values, and fpartial!(partial, ix) to its partials
773773
function _map_dual_components(fvalue!, fpartial!, x::AbstractArray{DT}) where DT <: Dual{<:Any, T} where T
774774
N = npartials(DT)
775-
@assert Base.elsize(x) == sizeof(T) * (N + 1) # check that accessing x as Vector{T} is possible
776775
res = similar(x) # result
777776
t = similar(x, T) # temporary Array{T} for fvalue!/fpartial! application
778-
ystride = N + 1
779-
# y allows res to be accessed as Vector{T}
780-
y = Base.unsafe_wrap(Array, Base.unsafe_convert(Ptr{T}, res),
781-
length(res) * ystride, own=false)
777+
# y allows res to be accessed as Array{T}
778+
y = reinterpret(reshape, T, res)
779+
@assert size(y) == (N + 1, length(res))
780+
ystride = size(y, 1)
782781

783782
# calculate res values
784783
@inbounds for (j, v) in enumerate(x)

0 commit comments

Comments
 (0)