Skip to content

Commit cf2d5c6

Browse files
feat: record all variables used in polynomial terms in PolynomialData
1 parent d39727e commit cf2d5c6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/systems/nonlinear/homotopy_continuation.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ end
121121
Information about an expression about its polynomial nature.
122122
"""
123123
mutable struct PolynomialData
124+
"""
125+
A list of the variables in the expression being searched that occur outside of
126+
any non-polynomial terms.
127+
"""
128+
solo_terms::Set{BasicSymbolic}
124129
"""
125130
A list of all non-polynomial terms in the expression.
126131
"""
@@ -136,7 +141,7 @@ mutable struct PolynomialData
136141
has_parametric_exponent::Bool
137142
end
138143

139-
PolynomialData() = PolynomialData(BasicSymbolic[], NonPolynomialReason.T[], false)
144+
PolynomialData() = PolynomialData(Set{BasicSymbolic}(), BasicSymbolic[], NonPolynomialReason.T[], false)
140145

141146
function is_polynomial!(data, y, wrt)
142147
process_polynomial!(data, y, wrt)
@@ -152,9 +157,12 @@ writing said information to `data`.
152157
function process_polynomial!(data::PolynomialData, x, wrt)
153158
x = unwrap(x)
154159
symbolic_type(x) == NotSymbolic() && return true
155-
iscall(x) || return true
156160
contains_variable(x, wrt) || return true
157-
any(isequal(x), wrt) && return true
161+
if any(isequal(x), wrt)
162+
push!(data.solo_terms, x)
163+
return true
164+
end
165+
iscall(x) || return true
158166

159167
if operation(x) in (*, +, -, /)
160168
# `map` because `all` will early exit, but we want to search

0 commit comments

Comments
 (0)