File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -263,19 +263,24 @@ add_divs(x, y::Div) = (x * y.den + y.num) / y.den
263263add_divs (x, y) = x + y
264264
265265"""
266- simplify_fractions(x)
266+ simplify_fractions(x; polyform=false )
267267
268268Find `Div` nodes and simplify them by cancelling a set of factors of numerators
269- and denominators. It may leave some expressions in `PolyForm` format.
269+ and denominators. If `polyform=true` the factors which were converted into PolyForm
270+ for the purpose of finding polynomial GCDs will be left as they are.
271+ Note that since PolyForms have different `hash`es than SymbolicUtils expressions,
272+ `substitute` may not work if `polyform=true`
270273"""
271- function simplify_fractions (x)
274+ function simplify_fractions (x; polyform = false )
272275 x = Postwalk (quick_cancel)(x)
273276
274277 ! needs_div_rules (x) && return x
275278
276279 sdiv (a) = a isa Div ? simplify_div (a) : a
277280
278- Postwalk (sdiv ∘ quick_cancel)(Postwalk (add_with_div)(x))
281+ expr = Postwalk (sdiv ∘ quick_cancel)(Postwalk (add_with_div)(x))
282+
283+ polyform ? expr : Postwalk (identity)(expr)
279284end
280285
281286function add_with_div (x, flatten= true )
You can’t perform that action at this time.
0 commit comments