Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rbed committed Aug 27, 2024
1 parent 58a045a commit 3cc5fd0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
11 changes: 9 additions & 2 deletions ext/SymbolicsGroebnerExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ function Symbolics.solve_multivar(eqs::Vector, vars::Vector{Num}; dropmultiplici
isempty(tr_basis) && return nothing
vars_gen = setdiff(vars, tr_basis)
sol = solve_zerodim(eqs, vars_gen; dropmultiplicity=dropmultiplicity, warns=warns)

for roots in sol
for x in tr_basis
roots[x] = x
end
end

sol
end

Expand All @@ -311,8 +318,8 @@ PrecompileTools.@setup_workload begin
PrecompileTools.@compile_workload begin
symbolic_solve(equation1, x)
symbolic_solve(equation_actually_polynomial)
symbolic_solve(simple_linear_equations, [x, y])
symbolic_solve(equations_intersect_sphere_line, [x, y, z])
symbolic_solve(simple_linear_equations, [x, y], warns=false)
symbolic_solve(equations_intersect_sphere_line, [x, y, z], warns=false)
end
end

Expand Down
5 changes: 1 addition & 4 deletions src/solver/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ function symbolic_solve(expr, x::T; dropmultiplicity = true, warns = true) where
for var in x
check_x(var)
end
if length(x) == 1
x = x[1]
x_univar = true
end
end

if !(expr isa Vector)
Expand Down Expand Up @@ -213,6 +209,7 @@ function symbolic_solve(expr; x...)
vars = wrap.(vars)
@assert all(v isa Num for v in vars) "All variables should be Nums or BasicSymbolics"

vars = isone(length(vars)) ? vars[1] : vars
return symbolic_solve(expr, vars; x...)
end

Expand Down
2 changes: 1 addition & 1 deletion test/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ end
@test isnothing(symbolic_solve([x*y - a, sin(x)], [x, y]))

@variables t w u v
sol = symbolic_solve([t*w - 1 ~ 4, u + v + w ~ 1], [t,w,u,v])
sol = symbolic_solve([t*w - 1 ~ 4, u + v + w ~ 1], [t,w])
@test isequal(sol, [Dict(t => -5 / (-1 + u + v), w => 1 - u - v)])
end

Expand Down

0 comments on commit 3cc5fd0

Please sign in to comment.