@@ -76,6 +76,10 @@ function get_dict(x::BasicSymbolic)
76
76
x. impl. dict
77
77
end
78
78
79
+ function get_num (x:: BasicSymbolic )
80
+ x. impl. num
81
+ end
82
+
79
83
# Same but different error messages
80
84
@noinline error_on_type () = error (" Internal error: unreachable reached!" )
81
85
@noinline error_sym () = error (" Sym doesn't have a operation or arguments!" )
@@ -303,7 +307,7 @@ function _isequal(a, b, E)
303
307
elseif E === ADD || E === MUL
304
308
coeff_isequal (get_coeff (a), get_coeff (b)) && isequal (get_dict (a), get_dict (b))
305
309
elseif E === DIV
306
- isequal (a . impl . num, b . impl . num ) && isequal (a. impl. den, b. impl. den)
310
+ isequal (get_num (a), get_num (b) ) && isequal (a. impl. den, b. impl. den)
307
311
elseif E === POW
308
312
isequal (a. impl. exp, b. impl. exp) && isequal (a. impl. base, b. impl. base)
309
313
elseif E === TERM
@@ -349,7 +353,7 @@ function Base.hash(s::BasicSymbolic, salt::UInt)::UInt
349
353
s. hash[] = h′
350
354
return h′
351
355
elseif E === DIV
352
- return hash (s . impl . num , hash (s. impl. den, salt ⊻ DIV_SALT))
356
+ return hash (get_num (s) , hash (s. impl. den, salt ⊻ DIV_SALT))
353
357
elseif E === POW
354
358
hash (s. impl. exp, hash (s. impl. base, salt ⊻ POW_SALT))
355
359
elseif E === TERM
@@ -483,11 +487,11 @@ function _Div(::Type{T}, num, den; kwargs...) where {T}
483
487
_iszero (num) && return zero (typeof (num))
484
488
_isone (den) && return num
485
489
if isdiv (num) && isdiv (den)
486
- return _Div (T, num. impl . num * den. impl. den, num. impl. den * den. impl . num )
490
+ return _Div (T, get_num ( num) * den. impl. den, num. impl. den * get_num ( den) )
487
491
elseif isdiv (num)
488
- return _Div (T, num. impl . num , num. impl. den * den)
492
+ return _Div (T, get_num ( num) , num. impl. den * den)
489
493
elseif isdiv (den)
490
- return _Div (T, num * den. impl. den, den. impl . num )
494
+ return _Div (T, num * den. impl. den, get_num ( den) )
491
495
end
492
496
if den isa Number && _isone (- den)
493
497
return - 1 * num
@@ -523,7 +527,7 @@ function _Div(num, den; kwargs...)
523
527
end
524
528
525
529
@inline function numerators (x)
526
- isdiv (x) && return numerators (x . impl . num )
530
+ isdiv (x) && return numerators (get_num (x) )
527
531
iscall (x) && operation (x) === (* ) ? arguments (x) : Any[x]
528
532
end
529
533
@@ -552,7 +556,7 @@ function toterm(t::BasicSymbolic{T}) where {T}
552
556
end
553
557
_Term (T, operation (t), args)
554
558
elseif E === DIV
555
- _Term (T, / , [t . impl . num , t. impl. den])
559
+ _Term (T, / , [get_num (t) , t. impl. den])
556
560
elseif E === POW
557
561
_Term (T, ^ , [t. impl. base, t. impl. exp])
558
562
else
@@ -1291,11 +1295,11 @@ function *(a::SN, b::SN)
1291
1295
# Always make sure Div wraps Mul
1292
1296
! issafecanon (* , a, b) && return term (* , a, b)
1293
1297
if isdiv (a) && isdiv (b)
1294
- _Div (a . impl . num * b . impl . num , a. impl. den * b. impl. den)
1298
+ _Div (get_num (a) * get_num (b) , a. impl. den * b. impl. den)
1295
1299
elseif isdiv (a)
1296
- _Div (a . impl . num * b, a. impl. den)
1300
+ _Div (get_num (a) * b, a. impl. den)
1297
1301
elseif isdiv (b)
1298
- _Div (a * b . impl . num , b. impl. den)
1302
+ _Div (a * get_num (b) , b. impl. den)
1299
1303
elseif ismul (a) && ismul (b)
1300
1304
_Mul (mul_t (a, b), get_coeff (a) * get_coeff (b),
1301
1305
_merge (+ , get_dict (a), get_dict (b), filter = _iszero))
@@ -1325,7 +1329,7 @@ function *(a::Number, b::SN)
1325
1329
elseif isone (a)
1326
1330
b
1327
1331
elseif isdiv (b)
1328
- _Div (a * b . impl . num , b. impl. den)
1332
+ _Div (a * get_num (b) , b. impl. den)
1329
1333
elseif isone (- a) && isadd (b)
1330
1334
# -1(a+b) -> -a - b
1331
1335
T = promote_symtype (+ , typeof (a), symtype (b))
0 commit comments