Skip to content

Commit

Permalink
Resoved differences
Browse files Browse the repository at this point in the history
  • Loading branch information
leespen1 committed Nov 27, 2024
1 parent 7d4ec7b commit 4fac978
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/eval_grad_discrete_adjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,20 @@ function recursive_magic!(grad_contrib::AbstractVector{<: Real},
# Move this outside the loop
right_inner = @view working_state_matrix[:,1+i]
right_inner .= 0

# Using views here might lead to type instability in next recursive_magic! call.
# Should check this with @code_warn
right_inner = view(working_state_matrix, :, 1+i)
working_state_matrix_reduced = view(working_state_matrix, :, 1:i)
right_inner .= 0
apply_hamiltonian!(right_inner, lambda, prob, controls, t, pcof;
derivative_order=(j-i), use_adjoint=true)


recursive_magic!(
grad_contrib, w_mat, right_inner, i, coeff/(j+1), prob,
controls, t, pcof, control_index, working_pcof, working_state_vector,
working_state_matrix,
working_state_matrix_reduced,
)
end

Expand Down

0 comments on commit 4fac978

Please sign in to comment.