diff --git a/src/config.jl b/src/config.jl index 3b80200..b713450 100644 --- a/src/config.jl +++ b/src/config.jl @@ -5,7 +5,7 @@ const Index = UInt16 const Delimiter = UInt16 const Exponent = UInt16 -struct PolyConfig{T} +mutable struct PolyConfig{T} monomials_delimiters::Vector{Delimiter} monomials::Vector{Index} grad_monomials_delimiters::Vector{Vector{Tuple{Delimiter, Exponent}}} diff --git a/src/poly.jl b/src/poly.jl index c183878..5b7d953 100644 --- a/src/poly.jl +++ b/src/poly.jl @@ -221,6 +221,7 @@ end (p::Polynomial)(x) = evaluate(p, x) +evaluate(F::Vector{<:Polynomial}, x::AbstractVector) = map(f -> evaluate(f, x), F) """ substitute(p::Polynomial, i, x) @@ -349,8 +350,8 @@ end Makes `p` homogenous, if `ishomogenized(p)` is `true` this is just the identity. The homogenization variable will always be considered as the first variable of the polynomial. """ -function homogenize(p::Polynomial, variable::Symbol=:x0) - if p.homogenized +function homogenize(p::Polynomial, variable::Symbol=:x0; respect_homogenous=true) + if p.homogenized || (respect_homogenous && ishomogenous(p)) p else monomials_degree = sum(exponents(p), 1)