@@ -6,10 +6,10 @@ function auto_jacvec!(
6
6
f,
7
7
x,
8
8
v,
9
- cache1 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(reshape (v, size (x))))),
9
+ cache1 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(reshape (v, size (x))))),
10
10
cache2 = similar (cache1),
11
11
)
12
- cache1 .= Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(reshape (v, size (x)))))
12
+ cache1 .= Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(reshape (v, size (x)))))
13
13
f (cache2, cache1)
14
14
vecdy = _vec (dy)
15
15
vecdy .= partials .(_vec (cache2), 1 )
@@ -20,7 +20,7 @@ _vec(v::AbstractVector) = v
20
20
21
21
function auto_jacvec (f, x, v)
22
22
vv = reshape (v, axes (x))
23
- y = ForwardDiff. Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(vv)))
23
+ y = ForwardDiff. Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(vv)))
24
24
vec (partials .(vec (f (y)), 1 ))
25
25
end
26
26
@@ -127,12 +127,12 @@ function autonum_hesvec!(
127
127
f,
128
128
x,
129
129
v,
130
- cache1 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(reshape (v, size (x))))),
131
- cache2 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(reshape (v, size (x))))),
130
+ cache1 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(reshape (v, size (x))))),
131
+ cache2 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(reshape (v, size (x))))),
132
132
)
133
133
cache = FiniteDiff. GradientCache (v[1 ], cache1, Val{:central })
134
134
g = (dx, x) -> FiniteDiff. finite_difference_gradient! (dx, f, x, cache)
135
- cache1 .= Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(reshape (v, size (x)))))
135
+ cache1 .= Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(reshape (v, size (x)))))
136
136
g (cache2, cache1)
137
137
dy .= partials .(cache2, 1 )
138
138
end
@@ -169,16 +169,16 @@ function auto_hesvecgrad!(
169
169
g,
170
170
x,
171
171
v,
172
- cache2 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(reshape (v, size (x))))),
173
- cache3 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(reshape (v, size (x))))),
172
+ cache2 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(reshape (v, size (x))))),
173
+ cache3 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(reshape (v, size (x))))),
174
174
)
175
- cache2 .= Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(reshape (v, size (x)))))
175
+ cache2 .= Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(reshape (v, size (x)))))
176
176
g (cache3, cache2)
177
177
dy .= partials .(cache3, 1 )
178
178
end
179
179
180
180
function auto_hesvecgrad (g, x, v)
181
- y = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(reshape (v, size (x)))))
181
+ y = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(reshape (v, size (x)))))
182
182
partials .(g (y), 1 )
183
183
end
184
184
194
194
195
195
function JacVec (f, x:: AbstractArray ; autodiff = true )
196
196
if autodiff
197
- cache1 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(x)))
198
- cache2 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(x)))
197
+ cache1 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(x)))
198
+ cache2 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(x)))
199
199
else
200
200
cache1 = similar (x)
201
201
cache2 = similar (x)
263
263
264
264
function HesVecGrad (g, x:: AbstractArray ; autodiff = false )
265
265
if autodiff
266
- cache1 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(x)))
267
- cache2 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(Tuple .(x)))
266
+ cache1 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(x)))
267
+ cache2 = Dual {typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1} .(x, ForwardDiff. Partials .(tuple .(x)))
268
268
else
269
269
cache1 = similar (x)
270
270
cache2 = similar (x)
0 commit comments