File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -82,18 +82,23 @@ Assumes `length(eqs) == length(vars)`
82
82
83
83
Currently only works if all equations are linear.
84
84
"""
85
- function solve_for (eqs, vars)
85
+ function solve_for (eqs, vars; simplify = true )
86
86
A, b = A_b (eqs, vars)
87
87
# TODO : we need to make sure that `solve_for(eqs, vars)` contains no `vars`
88
- _solve (A, b)
88
+ _solve (A, b, simplify )
89
89
end
90
90
91
- function _solve (A:: AbstractMatrix , b:: AbstractArray )
91
+ function _solve (A:: AbstractMatrix , b:: AbstractArray , do_simplify )
92
92
A = SymbolicUtils. simplify .(Num .(A), polynorm= true )
93
93
b = SymbolicUtils. simplify .(Num .(b), polynorm= true )
94
- value .(SymbolicUtils. simplify .(sym_lu (A) \ b))
94
+ sol = value .(sym_lu (A) \ b)
95
+ do_simplify ? SymbolicUtils. simplify .(sol, polynorm= true ) : sol
96
+ end
97
+
98
+ function _solve (a, b, do_simplify)
99
+ sol = value (b/ a)
100
+ do_simplify ? SymbolicUtils. simplify (sol, polynorm= true ) : sol
95
101
end
96
- _solve (a, b) = value (SymbolicUtils. simplify (b/ a, polynorm= true ))
97
102
98
103
# ldiv below
99
104
You can’t perform that action at this time.
0 commit comments