Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/back.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

@ChrisRackauckas ChrisRackauckas Aug 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

δ = false .* y .+ (1:length(y) .== i). Though you should then make it be color_i and loop through colors for it to be sparse, but this is good for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open a fresh PR for this.

δ[i] = true
return δ
end
vcat([transpose(back(ȳ(i))[1]) for i = 1:length(y)]...)
end

Expand Down