Skip to content

Commit

Permalink
reverted to original filter position
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rbed committed Aug 30, 2024
1 parent b0e130c commit 60de1a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
16 changes: 7 additions & 9 deletions ext/SymbolicsGroebnerExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ function solve_zerodim(eqs::Vector, vars::Vector{Num}; dropmultiplicity=true, wa
return []
end

for i in reverse(eachindex(new_eqs))
all_present = Symbolics.get_variables(new_eqs[i])
if length(intersect(all_present, vars)) < 1
deleteat!(new_eqs, i)
end
end

new_eqs = demote(new_eqs, vars, params)
new_eqs = map(Symbolics.unwrap, new_eqs)

Expand Down Expand Up @@ -294,19 +301,10 @@ function transendence_basis(sys, vars)
end

function Symbolics.solve_multivar(eqs::Vector, vars::Vector{Num}; dropmultiplicity=true, warns=true)
for i in reverse(eachindex(eqs))
present_vars = Symbolics.get_variables(eqs[i])
if length(intersect(present_vars, vars)) < 1 && length(present_vars) != 0
deleteat!(eqs, i)
end
end

sol = solve_zerodim(eqs, vars; dropmultiplicity=dropmultiplicity, warns=warns)
!isnothing(sol) && return sol

tr_basis = transendence_basis(eqs, vars)
isempty(tr_basis) && return nothing

vars_gen = setdiff(vars, tr_basis)
sol = solve_zerodim(eqs, vars_gen; dropmultiplicity=dropmultiplicity, warns=warns)

Expand Down
5 changes: 4 additions & 1 deletion test/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,13 @@ end
@test isequal(sol, [Dict(t => -5 / (-1 + u + v), w => 1 - u - v)])

sol = symbolic_solve([x-y, y-z], [x])
@test isequal(sol, [Dict(x=>y)])
@test isequal(sol, [Dict(x=>z)])

sol = symbolic_solve([x-y, y-z], [x, y])
@test isequal(sol, [Dict(x=>z, y=>z)])

sol = symbolic_solve([x + y - z, y - z], [x])
@test isequal(sol, [Dict(x=>0)])
end

@testset "Factorisation" begin
Expand Down

0 comments on commit 60de1a1

Please sign in to comment.