Skip to content

Commit c98f1ab

Browse files
Update gradients.jl
1 parent 5b639f7 commit c98f1ab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/gradients.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function finite_difference_gradient!(
247247
if ArrayInterface.fast_scalar_indexing(c2)
248248
epsilon = ArrayInterface.allowed_getindex(c2, i) * dir
249249
else
250-
epsilon = compute_epsilon(fdtype, x, relstep, absstep, dir) * dir
250+
epsilon = compute_epsilon(fdtype, one(eltype(x)), relstep, absstep, dir) * dir
251251
end
252252
c1_old = ArrayInterface.allowed_getindex(c1, i)
253253
ArrayInterface.allowed_setindex!(c1, c1_old + epsilon, i)
@@ -277,7 +277,7 @@ function finite_difference_gradient!(
277277
if ArrayInterface.fast_scalar_indexing(c2)
278278
epsilon = ArrayInterface.allowed_getindex(c2, i) * dir
279279
else
280-
epsilon = compute_epsilon(fdtype, x, relstep, absstep, dir) * dir
280+
epsilon = compute_epsilon(fdtype, one(eltype(x)), relstep, absstep, dir) * dir
281281
end
282282
c1_old = ArrayInterface.allowed_getindex(c1, i)
283283
ArrayInterface.allowed_setindex!(c1, c1_old + epsilon, i)

0 commit comments

Comments
 (0)