@@ -76,35 +76,19 @@ function instantiate_function(f, x, ::AutoForwardDiff{_chunksize}, p) where _chu
76
76
end
77
77
78
78
if cons != = nothing && f. cons_j === nothing
79
- if f. num_cons == 1
80
- cjconfig = ForwardDiff. JacobianConfig (cons, x, ForwardDiff. Chunk {chunksize} ())
81
- cons_j = (res,θ) -> ForwardDiff. jacobian! (res, cons, θ, cjconfig)
82
- else
83
- cons_j = function (res, θ)
84
- for i in 1 : f. num_cons
85
- consi = (x) -> cons (x)[i: i]
86
- cjconfig = ForwardDiff. JacobianConfig (consi, θ, ForwardDiff. Chunk {chunksize} ())
87
- ForwardDiff. jacobian! (res[i], consi, θ, cjconfig)
88
- end
89
- end
79
+ cons_j = function (J, θ)
80
+ cjconfig = ForwardDiff. JacobianConfig (cons, θ, ForwardDiff. Chunk {chunksize} ())
81
+ ForwardDiff. jacobian! (J, cons, θ, cjconfig)
90
82
end
91
83
else
92
84
cons_j = f. cons_j
93
85
end
94
86
95
87
if cons != = nothing && f. cons_h === nothing
96
- if f. num_cons == 1
97
- firstcons = (args... ) -> first (cons (args... ))
98
- cons_h = function (res, θ)
99
- hess_config_cache = ForwardDiff. HessianConfig (firstcons, θ, ForwardDiff. Chunk {chunksize} ())
100
- ForwardDiff. hessian! (res, firstcons, θ, hess_config_cache)
101
- end
102
- else
103
- cons_h = function (res, θ)
104
- for i in 1 : f. num_cons
105
- hess_config_cache = ForwardDiff. HessianConfig (x -> cons (x)[i], θ, ForwardDiff. Chunk {chunksize} ())
106
- ForwardDiff. hessian! (res[i], (x) -> cons (x)[i], θ, hess_config_cache, Val {false} ())
107
- end
88
+ cons_h = function (res, θ)
89
+ for i in 1 : f. num_cons
90
+ hess_config_cache = ForwardDiff. HessianConfig (x -> cons (x)[i], θ,ForwardDiff. Chunk {chunksize} ())
91
+ ForwardDiff. hessian! (res[i], (x) -> cons (x)[i], θ, hess_config_cache,Val {false} ())
108
92
end
109
93
end
110
94
else
0 commit comments