diff --git a/src/back.jl b/src/back.jl index e638e1ad..c34e2a73 100644 --- a/src/back.jl +++ b/src/back.jl @@ -173,7 +173,11 @@ Calculate the output jacobian `J = d/dx m(x)` such that each row `i` of `J` corr """ function jacobian(f, x::AbstractVector) y::AbstractVector, back = forward(f, x) - ȳ(i) = [i == j for j = 1:length(y)] + function ȳ(i) + δ = fill!(float(similar(data(y))), false) + δ[i] = true + return δ + end vcat([transpose(back(ȳ(i))[1]) for i = 1:length(y)]...) end