@@ -56,11 +56,11 @@ function OptimizationBase.instantiate_function(
5656 cons_vjp = f. cons_vjp === nothing ? nothing : (res, x) -> f. cons_vjp (res, x, p)
5757 cons_h = f. cons_h === nothing ? nothing : (res, x) -> f. cons_h (res, x, p)
5858 hess_prototype = f. hess_prototype === nothing ? nothing :
59- convert .( eltype (x), f . hess_prototype )
59+ similar (f . hess_prototype, eltype (x))
6060 cons_jac_prototype = f. cons_jac_prototype === nothing ? nothing :
61- convert .( eltype (x), f . cons_jac_prototype )
61+ similar (f . cons_jac_prototype, eltype (x))
6262 cons_hess_prototype = f. cons_hess_prototype === nothing ? nothing :
63- [convert .( eltype (x), f. cons_hess_prototype[i])
63+ [similar ( f. cons_hess_prototype[i], eltype (x) )
6464 for i in 1 : num_cons]
6565 expr = symbolify (f. expr)
6666 cons_expr = symbolify .(f. cons_expr)
@@ -90,11 +90,11 @@ function OptimizationBase.instantiate_function(
9090 cons_vjp = f. cons_vjp === nothing ? nothing : (res, x) -> f. cons_vjp (res, x, cache. p)
9191 cons_h = f. cons_h === nothing ? nothing : (res, x) -> f. cons_h (res, x, cache. p)
9292 hess_prototype = f. hess_prototype === nothing ? nothing :
93- convert .( eltype (cache. u0), f . hess_prototype )
93+ similar (f . hess_prototype, eltype (cache. u0))
9494 cons_jac_prototype = f. cons_jac_prototype === nothing ? nothing :
95- convert .( eltype (cache. u0), f . cons_jac_prototype )
95+ similar (f . cons_jac_prototype, eltype (cache. u0))
9696 cons_hess_prototype = f. cons_hess_prototype === nothing ? nothing :
97- [convert .( eltype (cache . u0), f. cons_hess_prototype[i])
97+ [similar ( f. cons_hess_prototype[i], eltype (cache . u0) )
9898 for i in 1 : num_cons]
9999 expr = symbolify (f. expr)
100100 cons_expr = symbolify .(f. cons_expr)
@@ -196,11 +196,11 @@ function OptimizationBase.instantiate_function(
196196 end
197197 end
198198 hess_prototype = f. hess_prototype === nothing ? nothing :
199- convert .( eltype (x), f . hess_prototype )
199+ similar (f . hess_prototype, eltype (x))
200200 cons_jac_prototype = f. cons_jac_prototype === nothing ? nothing :
201- convert .( eltype (x), f . cons_jac_prototype )
201+ similar (f . cons_jac_prototype, eltype (x))
202202 cons_hess_prototype = f. cons_hess_prototype === nothing ? nothing :
203- [convert .( eltype (x), f. cons_hess_prototype[i])
203+ [similar ( f. cons_hess_prototype[i], eltype (x) )
204204 for i in 1 : num_cons]
205205 expr = symbolify (f. expr)
206206 cons_expr = symbolify .(f. cons_expr)
0 commit comments