Separate the algebraic and numerical parts of the engine
This commit is contained in:
parent
af1d31f6e6
commit
b3b7c2026d
3 changed files with 233 additions and 222 deletions
25
engine-proto/Engine.Numerical.jl
Normal file
25
engine-proto/Engine.Numerical.jl
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Numerical
|
||||
|
||||
using AbstractAlgebra
|
||||
using HomotopyContinuation: Variable, Expression, System
|
||||
using ..Algebraic
|
||||
|
||||
# --- polynomial conversion ---
|
||||
|
||||
# hat tip Sascha Timme
|
||||
# https://github.com/JuliaHomotopyContinuation/HomotopyContinuation.jl/issues/520#issuecomment-1317681521
|
||||
function Base.convert(::Type{Expression}, f::MPolyRingElem)
|
||||
variables = Variable.(symbols(parent(f)))
|
||||
f_data = zip(coefficients(f), exponent_vectors(f))
|
||||
sum(cf * prod(variables .^ exp_vec) for (cf, exp_vec) in f_data)
|
||||
end
|
||||
|
||||
# create a ModelKit.System from an ideal in a multivariate polynomial ring. the
|
||||
# variable ordering is taken from the polynomial ring
|
||||
function System(I::Generic.Ideal)
|
||||
eqns = Expression.(gens(I))
|
||||
variables = Variable.(symbols(base_ring(I)))
|
||||
System(eqns, variables = variables)
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue