From a4ea9ba3b1e2b5539f7062bc6c0e4023baf611e6 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 18 Nov 2024 09:28:43 -0100 Subject: [PATCH 1/3] Update gradients.jl --- src/gradients.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gradients.jl b/src/gradients.jl index 2c32526..3ec0c94 100644 --- a/src/gradients.jl +++ b/src/gradients.jl @@ -238,7 +238,7 @@ function finite_difference_gradient!( # c1 denotes x1, c2 is epsilon fx, c1, c2, c3 = cache.fx, cache.c1, cache.c2, cache.c3 if fdtype != Val(:complex) && ArrayInterface.fast_scalar_indexing(c2) - @. c2 = compute_epsilon(fdtype, x, relstep, absstep, dir) + @. c2 = compute_epsilon(fdtype, one(eltype(x)), relstep, absstep, dir) copyto!(c1, x) end copyto!(c3, x) From 5b639f704ffdfcb417b6126dfdfda24e048e1d07 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 18 Nov 2024 09:29:20 -0100 Subject: [PATCH 2/3] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 9ad5411..9b97e28 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "FiniteDiff" uuid = "6a86dc24-6348-571c-b903-95158fe2bd41" -version = "2.26.0" +version = "2.26.1" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" From c98f1ab4f07c0a89d19b438463ae881aec567237 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 18 Nov 2024 09:30:56 -0100 Subject: [PATCH 3/3] Update gradients.jl --- src/gradients.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gradients.jl b/src/gradients.jl index 3ec0c94..54fec28 100644 --- a/src/gradients.jl +++ b/src/gradients.jl @@ -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) @@ -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)