Skip to content

Commit

Permalink
precompiled nemo
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rbed committed Aug 25, 2024
1 parent 02e4aff commit bf454dc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 1 addition & 2 deletions ext/SymbolicsGroebnerExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,17 @@ function Symbolics.solve_multivar(eqs::Vector, vars::Vector{Num}; dropmultiplici
sol
end

# Helps with precompilation time
PrecompileTools.@setup_workload begin
@variables a b c x y z
equation1 = a*log(x)^b + c ~ 0
equation_actually_polynomial = sin(x^2 +1)^2 + sin(x^2 + 1) + 3
simple_linear_equations = [x - y, y + 2z]
expr_with_params = expand((x + b)*(x^2 + 2x + 1)*(x^2 - a))
equations_intersect_sphere_line = [x^2 + y^2 + z^2 - 9, x - 2y + 3, y - z]
PrecompileTools.@compile_workload begin
symbolic_solve(equation1, x)
symbolic_solve(equation_actually_polynomial)
symbolic_solve(simple_linear_equations, [x, y])
symbolic_solve(expr_with_params, x, dropmultiplicity=false)
symbolic_solve(equations_intersect_sphere_line, [x, y, z])
end
end
Expand Down
13 changes: 13 additions & 0 deletions ext/SymbolicsNemoExt.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module SymbolicsNemoExt
using Nemo
import Symbolics.PrecompileTools

if isdefined(Base, :get_extension)
using Symbolics
Expand Down Expand Up @@ -73,4 +74,16 @@ function Symbolics.gcd_use_nemo(poly1::Num, poly2::Num)
return sym_gcd
end


# Helps with precompilation time
PrecompileTools.@setup_workload begin
@variables a b c x y z
expr_with_params = expand((x + b)*(x^2 + 2x + 1)*(x^2 - a))
PrecompileTools.@compile_workload begin
symbolic_solve(expr_with_params, x, dropmultiplicity=false)
symbolic_solve(x^10 - a^10, x, dropmultiplicity=false)
symbolic_solve([x^2 - a^2, x + a], x)
end
end

end # module
1 change: 1 addition & 0 deletions test/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ end
@testset "Multipoly solver" begin
@test isequal(symbolic_solve([x^2 - 1, x + 1], x)[1], -1)
@test isequal(symbolic_solve([x^2 - a^2, x + a], x)[1], -a)
@test isequal(symbolic_solve([x^20 - a^20, x + a], x)[1], -a)
end
@testset "Multivar solver" begin
@variables x y z
Expand Down

0 comments on commit bf454dc

Please sign in to comment.