@@ -34,11 +34,11 @@ function _finite_difference_jacobian!(J::AbstractMatrix{<:Real}, f,
34
34
if typeof (fx) == Void
35
35
fx = similar (x,returntype)
36
36
end
37
- f (fx,x)
38
37
# TODO : Remove these allocations
39
38
fx2 = similar (x,returntype)
40
39
shifted_x = copy (x)
41
40
epsilon_factor = compute_epsilon_factor (Val{:forward }, epsilon_elemtype)
41
+ f (fx,x)
42
42
@inbounds for i in 1 : n
43
43
epsilon = compute_epsilon (Val{:forward }, x[i], epsilon_factor)
44
44
shifted_x[i] += epsilon
@@ -96,13 +96,12 @@ function _finite_difference_jacobian!(J::AbstractMatrix{<:Number}, f,
96
96
if typeof (fx) == Void
97
97
fx = similar (x,returntype)
98
98
end
99
- f (fx,x)
100
99
# TODO : Remove these allocations
101
100
fx2 = similar (x,returntype)
102
101
shifted_x = copy (x)
103
102
104
103
epsilon_factor = compute_epsilon_factor (Val{:forward }, epsilon_elemtype)
105
-
104
+ f (fx,x)
106
105
@inbounds for i in 1 : n
107
106
epsilon = compute_epsilon (Val{:forward }, real (x[i]), epsilon_factor)
108
107
shifted_x[i] += epsilon
@@ -148,9 +147,7 @@ function _finite_difference_jacobian!(J::AbstractMatrix{<:Real}, f,
148
147
m, n = size (J)
149
148
epsilon_elemtype = compute_epsilon_elemtype (epsilon, x)
150
149
if fdtype == Val{:forward }
151
- if typeof (fx) == Void
152
- fx = f (x)
153
- end
150
+ fx = f (x)
154
151
epsilon_factor = compute_epsilon_factor (Val{:forward }, epsilon_elemtype)
155
152
shifted_x = copy (x)
156
153
@inbounds for i in 1 : n
0 commit comments