Skip to content

Commit

Permalink
isaffine errors for some differential equations, catched these errors…
Browse files Browse the repository at this point in the history
… in case they happen, so now the function relies on linear_expansion for these cases
  • Loading branch information
n0rbed committed Mar 28, 2024
1 parent 2833cf6 commit 4514152
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/linear_algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,19 @@ function solve_for(eq, var; simplify=false, check=true) # scalar case

if eq isa AbstractArray
for eqᵢ in eq
islinear &= Symbolics.isaffine(eqᵢ.lhs-eqᵢ.rhs, var)
try
islinear &= Symbolics.isaffine(eqᵢ.lhs-eqᵢ.rhs, var)
catch e
end
end
else
islinear &= Symbolics.isaffine(eq.lhs-eq.rhs, [var])
try
islinear &= Symbolics.isaffine(eq.lhs-eq.rhs, [var])
catch e
end
end

islinear || return nothing
if !islinear return nothing end
# a * x + b = 0
if eq isa AbstractArray && var isa AbstractArray
x = _solve(a, -b, simplify)
Expand Down

0 comments on commit 4514152

Please sign in to comment.