Skip to content

Commit

Permalink
Update gradients.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas authored Nov 18, 2024
1 parent 5b639f7 commit c98f1ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gradients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function finite_difference_gradient!(
if ArrayInterface.fast_scalar_indexing(c2)
epsilon = ArrayInterface.allowed_getindex(c2, i) * dir
else
epsilon = compute_epsilon(fdtype, x, relstep, absstep, dir) * dir
epsilon = compute_epsilon(fdtype, one(eltype(x)), relstep, absstep, dir) * dir
end
c1_old = ArrayInterface.allowed_getindex(c1, i)
ArrayInterface.allowed_setindex!(c1, c1_old + epsilon, i)
Expand Down Expand Up @@ -277,7 +277,7 @@ function finite_difference_gradient!(
if ArrayInterface.fast_scalar_indexing(c2)
epsilon = ArrayInterface.allowed_getindex(c2, i) * dir
else
epsilon = compute_epsilon(fdtype, x, relstep, absstep, dir) * dir
epsilon = compute_epsilon(fdtype, one(eltype(x)), relstep, absstep, dir) * dir
end
c1_old = ArrayInterface.allowed_getindex(c1, i)
ArrayInterface.allowed_setindex!(c1, c1_old + epsilon, i)
Expand Down

0 comments on commit c98f1ab

Please sign in to comment.