Skip to content

Commit 1156c83

Browse files
Merge pull request #14 from YingboMa/master
Taking inplace Jacobian for AbstractArray
2 parents d21022e + 63c18df commit 1156c83

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/finitediff.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,19 @@ function finite_difference_jacobian!(J::AbstractArray{T}, f, x::AbstractArray{T}
160160
# This is an inefficient fallback that only makes sense if setindex/getindex are unavailable, e.g. GPUArrays etc.
161161
m, n = size(J)
162162
epsilon_factor = compute_epsilon_factor(fdtype, T)
163-
if t == Val{:forward}
163+
if fdtype == Val{:forward}
164164
shifted_x = copy(x)
165165
for i in 1:n
166166
epsilon = compute_epsilon(t, x[i], epsilon_factor)
167167
shifted_x[i] += epsilon
168168
J[:, i] .= (f(shifted_x) - f_x) / epsilon
169169
shifted_x[i] = x[i]
170170
end
171-
elseif t == Val{:central}
171+
elseif fdtype == Val{:central}
172172
shifted_x_plus = copy(x)
173173
shifted_x_minus = copy(x)
174174
for i in 1:n
175-
epsilon = compute_epsilon(t, x[i], epsilon_factor)
175+
epsilon = compute_epsilon(fdtype, x[i], epsilon_factor)
176176
shifted_x_plus[i] += epsilon
177177
shifted_x_minus[i] -= epsilon
178178
J[:, i] .= (f(shifted_x_plus) - f(shifted_x_minus)) / (epsilon + epsilon)

0 commit comments

Comments
 (0)