File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 4545# return the coefficient matrix `A` and a
4646# vector of constants (possibly symbolic) `b` such that
4747# A \ b will solve the equations for the vars
48- function A_b (eqs, vars)
48+ function A_b (eqs:: AbstractArray , vars:: AbstractArray )
4949 exprs = rhss (eqs) .- lhss (eqs)
5050 for ex in exprs
5151 @assert islinear (ex, vars)
@@ -54,6 +54,13 @@ function A_b(eqs, vars)
5454 b = A * vars - exprs
5555 A, b
5656end
57+ function A_b (eq, var)
58+ ex = eq. rhs - eq. lhs
59+ @assert islinear (ex, [var])
60+ a = expand_derivatives (Differential (var)(ex))
61+ b = a * var - ex
62+ a, b
63+ end
5764
5865"""
5966 solve_for(eqs::Vector, vars::Vector)
@@ -69,11 +76,12 @@ function solve_for(eqs, vars)
6976 _solve (A, b)
7077end
7178
72- function _solve (A, b)
79+ function _solve (A:: AbstractMatrix , b:: AbstractArray )
7380 A = SymbolicUtils. simplify .(to_symbolic .(A), polynorm= true )
7481 b = SymbolicUtils. simplify .(to_symbolic .(b), polynorm= true )
7582 SymbolicUtils. simplify .(ldiv (sym_lu (A), b))
7683end
84+ _solve (a, b) = value (SymbolicUtils. simplify (b/ a, polynorm= true ))
7785
7886# ldiv below
7987
You can’t perform that action at this time.
0 commit comments