Skip to content

Commit

Permalink
added @views in generated functions (onepass)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcaillau committed Sep 9, 2024
1 parent 34f2d99 commit ff75ab0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/onepass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ p_constraint!(p, ocp, e1, e2, e3, label = gensym(); log = false) = begin
__v_dep(p) && push!(args, p.v)
quote
function $gs($(args...))
$r[:] .= $ee2
@views $r[:] .= $ee2
return nothing
end
constraint!($ocp, :boundary; f = $gs, lb = $e1, ub = $e3, label = $llabel)
Expand All @@ -380,7 +380,7 @@ p_constraint!(p, ocp, e1, e2, e3, label = gensym(); log = false) = begin
__v_dep(p) && push!(args, p.v)
quote
function $gs($(args...))
$r[:] .= $ee2
@views $r[:] .= $ee2
return nothing
end
constraint!($ocp, :control; f = $gs, lb = $e1, ub = $e3, label = $llabel)
Expand All @@ -400,7 +400,7 @@ p_constraint!(p, ocp, e1, e2, e3, label = gensym(); log = false) = begin
__v_dep(p) && push!(args, p.v)
quote
function $gs($(args...))
$r[:] .= $ee2
@views $r[:] .= $ee2
return nothing
end
constraint!($ocp, :state; f = $gs, lb = $e1, ub = $e3, label = $llabel)
Expand All @@ -414,7 +414,7 @@ p_constraint!(p, ocp, e1, e2, e3, label = gensym(); log = false) = begin
args = [r, p.v]
quote
function $gs($(args...))
$r[:] .= $e2
@views $r[:] .= $e2
return nothing
end
constraint!($ocp, :variable; f = $gs, lb = $e1, ub = $e3, label = $llabel)
Expand All @@ -433,7 +433,7 @@ p_constraint!(p, ocp, e1, e2, e3, label = gensym(); log = false) = begin
__v_dep(p) && push!(args, p.v)
quote
function $gs($(args...))
$r[:] .= $ee2
@views $r[:] .= $ee2
return nothing
end
constraint!($ocp, :mixed; f = $gs, lb = $e1, ub = $e3, label = $llabel)
Expand Down Expand Up @@ -462,7 +462,7 @@ p_dynamics!(p, ocp, x, t, e, label = nothing; log = false) = begin
args = [r]; __t_dep(p) && push!(args, p.t); push!(args, xt, ut); __v_dep(p) && push!(args, p.v)
code = quote
function $gs($(args...))
$r[:] .= $e
@views $r[:] .= $e
return nothing
end
dynamics!($ocp, $gs)
Expand All @@ -485,7 +485,7 @@ p_lagrange!(p, ocp, e, type; log = false) = begin
args = [r]; __t_dep(p) && push!(args, p.t); push!(args, xt, ut); __v_dep(p) && push!(args, p.v)
code = quote
function $gs($(args...))
$r[:] .= $e
@views $r[:] .= $e
return nothing
end
objective!($ocp, :lagrange, $gs, $ttype)
Expand Down Expand Up @@ -513,7 +513,7 @@ p_mayer!(p, ocp, e, type; log = false) = begin
args = [r, x0, xf]; __v_dep(p) && push!(args, p.v)
code = quote
function $gs($(args...))
$r[:] .= $e
@views $r[:] .= $e
return nothing
end
objective!($ocp, :mayer, $gs, $ttype)
Expand Down

0 comments on commit ff75ab0

Please sign in to comment.