Skip to content

Commit e69c962

Browse files
Use build_function in generate_jacobian
1 parent 5d14526 commit e69c962

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/systems/systems.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@ function system_eqs end
77
function system_vars end
88
function system_params end
99

10-
function generate_jacobian(sys::AbstractSystem)
10+
function generate_jacobian(sys::AbstractSystem; version = ArrayFunction)
1111
vs, ps = system_vars(sys), system_params(sys)
12-
var_exprs = [:($(vs[i].name) = u[$i]) for i in eachindex(vs)]
13-
param_exprs = [:($(ps[i].name) = p[$i]) for i in eachindex(ps)]
1412
jac = calculate_jacobian(sys)
15-
jac_exprs = [:(J[$i,$j] = $(convert(Expr, jac[i,j]))) for i in 1:size(jac,1), j in 1:size(jac,2)]
16-
exprs = vcat(var_exprs, param_exprs, vec(jac_exprs))
17-
block = expr_arr_to_block(exprs)
18-
:((J,u,p,t) -> $(block))
13+
return build_function(jac, vs, ps, (:t,); version = version)
1914
end
2015

2116
function generate_function(sys::AbstractSystem; version::FunctionVersion = ArrayFunction)

0 commit comments

Comments
 (0)