File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -1189,6 +1189,8 @@ and the rational/integer factor (or `NaN` otherwise).
11891189function ratcoeff (x)
11901190 if iscall (x) && operation (x) === (* )
11911191 ratcoeff (get_mul_coefficient (x))
1192+ elseif safe_isinteger (x)
1193+ (true , Int (x))
11921194 elseif x isa Rat
11931195 (true , x)
11941196 else
@@ -1202,6 +1204,12 @@ end
12021204Simplify the coefficients of `n` and `d` (numerator and denominator).
12031205"""
12041206function simplify_coefficients (n, d)
1207+ if safe_isinteger (n)
1208+ n = Int (n)
1209+ end
1210+ if safe_isinteger (d)
1211+ d = Int (d)
1212+ end
12051213 nrat, nc = ratcoeff (n)
12061214 drat, dc = ratcoeff (d)
12071215 nrat && drat || return n, d
Original file line number Diff line number Diff line change 11using Base: ImmutableDict
22
33safe_isinteger (x:: Number ) = isinteger (x) && abs (x) < typemax (Int)
4+ safe_isinteger (x) = false
45
56pow (x,y) = y== 0 ? 1 : y< 0 ? inv (x)^ (- y) : x^ y
67pow (x:: BasicSymbolic ,y) = y== 0 ? 1 : Base.:^ (x,y)
You can’t perform that action at this time.
0 commit comments