Skip to content

Commit

Permalink
var conflict prevented
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rbed committed Jul 31, 2024
1 parent f3e6cf9 commit 217cbf7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext/SymbolicsGroebnerExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function Symbolics.solve_multivar(eqs::Vector, vars::Vector{Num}, mult=false)
# AAECC 9, 433–461 (1999). https://doi.org/10.1007/s002000050114

# Use a new variable to separate the input polynomials (Reference above)
new_var = (@variables HAT)[1]
new_var = Symbolics.gen_separating_var(vars)
old_len = length(vars)
push!(vars, new_var)

Expand Down
11 changes: 11 additions & 0 deletions src/solver/solve_helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,14 @@ function add_sol_to_all(solutions, new_sols, var)
return solutions
end

function gen_separating_var(vars)
n = 1
new_var = (@variables HAT)[1]
present = any(isequal(new_var, var) for var in vars)
while present
new_var = variables(repeat("_", n)*"HAT")[1]
present = any(isequal(new_var, var) for var in vars)
n += 1
end
return new_var
end
3 changes: 2 additions & 1 deletion src/solver/univar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ function get_roots_deg4(expression, x)

r = comp_rational((-3(b^4) + 256(e*a^3) - 64(d*b*a^2) + 16(c*(b^2)*a)), (256*a^4))

@variables m
m = gensym()
m = (@variables $m)[1]
eq_m = 8m^3 + 8(p)*m^2 + (2(p^2) - 8r)m - q^2

roots_m = solve_univar(eq_m, m)
Expand Down

0 comments on commit 217cbf7

Please sign in to comment.