From 359cc86c9018c72f012eae855ed0160e52c8e98e Mon Sep 17 00:00:00 2001 From: Vitalij Ruge Date: Mon, 15 Dec 2014 18:38:36 +0000 Subject: [PATCH] ExpressionSimplify.simplify2: - fixed simplifyMulJoinFactorsFind for case "e11-e12 and e12-e11, negative -1.0 factor" git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23792 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- Compiler/FrontEnd/ExpressionSimplify.mo | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Compiler/FrontEnd/ExpressionSimplify.mo b/Compiler/FrontEnd/ExpressionSimplify.mo index 1cef58d925e..f331cf5d919 100644 --- a/Compiler/FrontEnd/ExpressionSimplify.mo +++ b/Compiler/FrontEnd/ExpressionSimplify.mo @@ -2566,7 +2566,7 @@ algorithm Real coeff2,coeff3,coeff; list> res,rest; DAE.Exp e,e2,e1; - Type tp; + DAE.Operator op; case (_,{}) then (0.0,{}); @@ -2578,11 +2578,11 @@ algorithm then (coeff3,res); - case (e,((DAE.BINARY(exp1 = e1,operator = DAE.SUB(ty = tp),exp2 = e2),coeff) :: rest)) /* e11-e12 and e12-e11, negative -1.0 factor */ + case (e,((DAE.BINARY(exp1 = e1,operator = op as DAE.DIV(),exp2 = e2),coeff) :: rest)) // pow(a/b,n) * pow(b/a,m) = pow(a/b,n-m) equation - true = Expression.expEqual(e, DAE.BINARY(e2,DAE.SUB(tp),e1)); + true = if Expression.isOne(e1) then Expression.expEqual(e, e2) else Expression.expEqual(e, DAE.BINARY(e2, op, e1)); (coeff2,res) = simplifyMulJoinFactorsFind(e, rest); - coeff3 = coeff - coeff2; + coeff3 = coeff2 - coeff; then (coeff3,res);