121121Information about an expression about its polynomial nature.
122122"""
123123mutable 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
137142end
138143
139- PolynomialData () = PolynomialData (BasicSymbolic[], NonPolynomialReason. T[], false )
144+ PolynomialData () = PolynomialData (Set {BasicSymbolic} (), BasicSymbolic[], NonPolynomialReason. T[], false )
140145
141146function is_polynomial! (data, y, wrt)
142147 process_polynomial! (data, y, wrt)
@@ -152,9 +157,12 @@ writing said information to `data`.
152157function 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