201201
202202# ## Operator Forms
203203
204- struct FwdModeAutoDiffVecProd{F,U,C,V, V!} <: AbstractAutoDiffVecProd
204+ struct FwdModeAutoDiffVecProd{F, U, C, V, V!} <: AbstractAutoDiffVecProd
205205 f:: F
206206 u:: U
207207 cache:: C
@@ -230,16 +230,15 @@ end
230230
231231function JacVec (f, u:: AbstractArray , p = nothing , t = nothing ; autodiff = AutoForwardDiff (),
232232 kwargs... )
233-
234233 cache, vecprod, vecprod! = if autodiff isa AutoFiniteDiff
235234 cache1 = similar (u)
236235 cache2 = similar (u)
237236
238237 (cache1, cache2), num_jacvec, num_jacvec!
239238 elseif autodiff isa AutoForwardDiff
240239 cache1 = Dual{
241- typeof (ForwardDiff. Tag (DeivVecTag (),eltype (u))), eltype (u), 1
242- }. (u, ForwardDiff. Partials .(tuple .(u)))
240+ typeof (ForwardDiff. Tag (DeivVecTag (), eltype (u))), eltype (u), 1
241+ }. (u, ForwardDiff. Partials .(tuple .(u)))
243242
244243 cache2 = copy (cache1)
245244
@@ -249,7 +248,7 @@ function JacVec(f, u::AbstractArray, p = nothing, t = nothing; autodiff = AutoFo
249248 end
250249
251250 outofplace = static_hasmethod (f, typeof ((u,)))
252- isinplace = static_hasmethod (f, typeof ((u, u, )))
251+ isinplace = static_hasmethod (f, typeof ((u, u)))
253252
254253 if ! (isinplace) & ! (outofplace)
255254 error (" $f must have signature f(u), or f(du, u)." )
@@ -260,13 +259,11 @@ function JacVec(f, u::AbstractArray, p = nothing, t = nothing; autodiff = AutoFo
260259 FunctionOperator (L, u, u;
261260 isinplace = isinplace, outofplace = outofplace,
262261 p = p, t = t, islinear = true ,
263- kwargs... ,
264- )
262+ kwargs... )
265263end
266264
267265function HesVec (f, u:: AbstractArray , p = nothing , t = nothing ; autodiff = AutoForwardDiff (),
268266 kwargs... )
269-
270267 cache, vecprod, vecprod! = if autodiff isa AutoFiniteDiff
271268 cache1 = similar (u)
272269 cache2 = similar (u)
@@ -283,8 +280,8 @@ function HesVec(f, u::AbstractArray, p = nothing, t = nothing; autodiff = AutoFo
283280 @assert static_hasmethod (autoback_hesvec, typeof ((f, u, u))) " To use AutoZygote() AD, first load Zygote with `using Zygote`, or `import Zygote`"
284281
285282 cache1 = Dual{
286- typeof (ForwardDiff. Tag (DeivVecTag (),eltype (u))), eltype (u), 1
287- }. (u, ForwardDiff. Partials .(tuple .(u)))
283+ typeof (ForwardDiff. Tag (DeivVecTag (), eltype (u))), eltype (u), 1
284+ }. (u, ForwardDiff. Partials .(tuple .(u)))
288285 cache2 = copy (cache1)
289286
290287 (cache1, cache2), autoback_hesvec, autoback_hesvec!
@@ -293,7 +290,7 @@ function HesVec(f, u::AbstractArray, p = nothing, t = nothing; autodiff = AutoFo
293290 end
294291
295292 outofplace = static_hasmethod (f, typeof ((u,)))
296- isinplace = static_hasmethod (f, typeof ((u,)))
293+ isinplace = static_hasmethod (f, typeof ((u,)))
297294
298295 if ! (isinplace) & ! (outofplace)
299296 error (" $f must have signature f(u)." )
@@ -304,13 +301,12 @@ function HesVec(f, u::AbstractArray, p = nothing, t = nothing; autodiff = AutoFo
304301 FunctionOperator (L, u, u;
305302 isinplace = isinplace, outofplace = outofplace,
306303 p = p, t = t, islinear = true ,
307- kwargs... ,
308- )
304+ kwargs... )
309305end
310306
311- function HesVecGrad (f, u:: AbstractArray , p = nothing , t = nothing ; autodiff = AutoForwardDiff (),
307+ function HesVecGrad (f, u:: AbstractArray , p = nothing , t = nothing ;
308+ autodiff = AutoForwardDiff (),
312309 kwargs... )
313-
314310 cache, vecprod, vecprod! = if autodiff isa AutoFiniteDiff
315311 cache1 = similar (u)
316312 cache2 = similar (u)
@@ -319,7 +315,7 @@ function HesVecGrad(f, u::AbstractArray, p = nothing, t = nothing; autodiff = Au
319315 elseif autodiff isa AutoForwardDiff
320316 cache1 = Dual{
321317 typeof (ForwardDiff. Tag (DeivVecTag (), eltype (u))), eltype (u), 1
322- }. (u, ForwardDiff. Partials .(tuple .(u)))
318+ }. (u, ForwardDiff. Partials .(tuple .(u)))
323319 cache2 = copy (cache1)
324320
325321 (cache1, cache2), auto_hesvecgrad, auto_hesvecgrad!
@@ -328,7 +324,7 @@ function HesVecGrad(f, u::AbstractArray, p = nothing, t = nothing; autodiff = Au
328324 end
329325
330326 outofplace = static_hasmethod (f, typeof ((u,)))
331- isinplace = static_hasmethod (f, typeof ((u, u, )))
327+ isinplace = static_hasmethod (f, typeof ((u, u)))
332328
333329 if ! (isinplace) & ! (outofplace)
334330 error (" $f must have signature f(u), or f(du, u)." )
@@ -339,7 +335,6 @@ function HesVecGrad(f, u::AbstractArray, p = nothing, t = nothing; autodiff = Au
339335 FunctionOperator (L, u, u;
340336 isinplace = isinplace, outofplace = outofplace,
341337 p = p, t = t, islinear = true ,
342- kwargs... ,
343- )
338+ kwargs... )
344339end
345340#
0 commit comments