Skip to content

Commit

Permalink
changed filter location
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rbed committed Aug 30, 2024
1 parent c16933b commit b0e130c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 9 additions & 7 deletions ext/SymbolicsGroebnerExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,6 @@ 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 @@ -301,10 +294,19 @@ 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,7 +283,10 @@ 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=>z)])
@test isequal(sol, [Dict(x=>y)])

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

@testset "Factorisation" begin
Expand Down

0 comments on commit b0e130c

Please sign in to comment.