Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #961, solve_for outputting wrong answers when function is nonlinear. #1101

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/linear_algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,22 @@ function solve_for(eq, var; simplify=false, check=true) # scalar case
# the cases.
a, b, islinear = linear_expansion(eq, var)
check && @assert islinear
islinear || return nothing

if eq isa AbstractArray
for eqᵢ in eq
try
islinear &= Symbolics.isaffine(eqᵢ.lhs-eqᵢ.rhs, var)
catch e
end
Comment on lines +103 to +107
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of try/catch, the root issue should be handled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. this is just a temporary fix. Want me to open an issue on the failed tests for isaffine?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes please

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, the current PR temporarily solves issue #961 and passes all the CI tests (i think the integration tests will fail nontheless, correct me if i'm wrong)

end
else
try
islinear &= Symbolics.isaffine(eq.lhs-eq.rhs, [var])
catch e
end
end

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