Skip to content

Commit 22b7ded

Browse files
Incorrect convert call for cons_hess_prototype since it's a vector of matrices
1 parent 85af4e4 commit 22b7ded

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/function/function.jl

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,15 @@ For more information on the use of automatic differentiation, see the
4444
documentation of the `AbstractADType` types.
4545
"""
4646
function instantiate_function(f, x, ::AbstractADType, p, num_cons = 0)
47-
grad = f.grad === nothing ? nothing : (G, x) -> f.grad(G, x, p)
48-
hess = f.hess === nothing ? nothing : (H, x) -> f.hess(H, x, p)
49-
hv = f.hv === nothing ? nothing : (H, x, v) -> f.hv(H, x, v, p)
50-
cons = f.cons === nothing ? nothing : (res, x) -> f.cons(res, x, p)
51-
cons_j = f.cons_j === nothing ? nothing : (res, x) -> f.cons_j(res, x, p)
52-
cons_h = f.cons_h === nothing ? nothing : (res, x) -> f.cons_h(res, x, p)
53-
hess_prototype = f.hess_prototype === nothing ? nothing :
54-
convert.(eltype(x), f.hess_prototype)
55-
cons_jac_prototype = f.cons_jac_prototype === nothing ? nothing :
56-
convert.(eltype(x), f.cons_jac_prototype)
57-
cons_hess_prototype = f.cons_hess_prototype === nothing ? nothing :
58-
convert.(eltype(x), f.cons_hess_prototype)
47+
grad = f.grad === nothing ? nothing : (G,x)->f.grad(G,x,p)
48+
hess = f.hess === nothing ? nothing : (H,x)->f.hess(H,x,p)
49+
hv = f.hv === nothing ? nothing : (H,x,v)->f.hv(H,x,v,p)
50+
cons = f.cons === nothing ? nothing : (res,x)->f.cons(res,x,p)
51+
cons_j = f.cons_j === nothing ? nothing : (res,x)->f.cons_j(res,x,p)
52+
cons_h = f.cons_h === nothing ? nothing : (res,x)->f.cons_h(res,x,p)
53+
hess_prototype = f.hess_prototype === nothing ? nothing : convert.(eltype(x), f.hess_prototype)
54+
cons_jac_prototype = f.cons_jac_prototype === nothing ? nothing : convert.(eltype(x), f.cons_jac_prototype)
55+
cons_hess_prototype = f.cons_hess_prototype === nothing ? nothing : [convert.(eltype(x), f.cons_hess_prototype[i]) for i in 1:num_cons]
5956
expr = symbolify(f.expr)
6057
cons_expr = symbolify.(f.cons_expr)
6158

0 commit comments

Comments
 (0)