Commit c3a09fa6 authored by Thierry Martinez's avatar Thierry Martinez

Better simplification

parent 5ad28081
......@@ -38,17 +38,24 @@ simplify_aux(In, Out) :-
rebuild_multiplicative_blocks(CoefSubBlocksComputed, OutCoef),
(
extract_coefficient(OutCoef, Coef, SubOut),
Coef < 0
Coef < 1
->
CoefOpp is - Coef,
(
CoefOpp = 1
Coef < 0
->
OutOpp = SubOut
CoefAbs is - Coef,
Out = - OutAbs
;
insert_coef(SubOut, CoefOpp, OutOpp)
CoefAbs = Coef,
Out = OutAbs
),
Out = - OutOpp
(
CoefAbs = 1
->
OutAbs = SubOut
;
insert_coef(SubOut, CoefAbs, OutAbs)
)
;
Out = OutCoef
).
......@@ -376,9 +383,10 @@ insert_coef(A * B, Coef, Result * B) :-
insert_coef(A, Coef, Result) :-
(
Coef > 0,
Coef < 1
->
Coef < 1,
CoefInv is 1 / Coef,
0.0 is float_fractional_part(CoefInv)
->
normalize_number(CoefInv, CoefInvNorm),
Result = A / CoefInvNorm
;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment