Skip to content

Commit 559e1ed

Browse files
committed
simplify y
1 parent 7db106d commit 559e1ed

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
@@ -780,13 +780,12 @@ end
780780
# creates the copy of x and applies fvalue!(values) to its values, and fpartial!(partial, ix) to its partials
781781
function _map_dual_components(fvalue!, fpartial!, x::AbstractArray{DT}) where DT <: Dual{<:Any, T} where T
782782
N = npartials(DT)
783-
@assert Base.elsize(x) == sizeof(T) * (N + 1) # check that accessing x as Vector{T} is possible
784783
res = similar(x) # result
785784
t = similar(x, T) # temporary Array{T} for fvalue!/fpartial! application
786-
ystride = N + 1
787-
# y allows res to be accessed as Vector{T}
788-
y = Base.unsafe_wrap(Array, Base.unsafe_convert(Ptr{T}, res),
789-
length(res) * ystride, own=false)
785+
# y allows res to be accessed as Array{T}
786+
y = reinterpret(reshape, T, res)
787+
@assert size(y) == (N + 1, length(res))
788+
ystride = size(y, 1)
790789

791790
# calculate res values
792791
@inbounds for (j, v) in enumerate(x)

0 commit comments

Comments
 (0)