Skip to content

Commit f7d06d5

Browse files
committed
use linear_expansion
1 parent 457bf96 commit f7d06d5

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/input_affine_form.jl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,10 @@ f, g = input_affine_form(eqs, inputs)
3939
4040
# Notes
4141
The function assumes that the equations are affine in the inputs. If the equations
42-
are nonlinear in the inputs, the result may not be meaningful.
42+
are nonlinear in the inputs, an error is thrown.
4343
"""
4444
function input_affine_form(eqs, inputs)
45-
# Extract the input matrix g(x) by taking coefficients of each input
46-
g = [Symbolics.coeff(Symbolics.simplify(eq, expand = true), u)
47-
for eq in eqs, u in inputs]
48-
g = Symbolics.simplify.(g, expand = true)
49-
50-
# Extract the drift term f(x) by substituting inputs = 0
51-
f = Symbolics.fast_substitute.(eqs, Ref(Dict(inputs .=> 0)))
52-
f = Symbolics.simplify.(f, expand = true)
53-
45+
g, f, flag = linear_expansion(eqs, inputs)
46+
flag || error("The system is not affine in the inputs.")
5447
return f, g
5548
end

0 commit comments

Comments
 (0)