Skip to content

Commit

Permalink
- simplifyBinary: add case for (a*b)/a = b and (-a*b)/a = -b
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8376 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Mar 27, 2011
1 parent 4111c1f commit 5ac85b6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -3314,6 +3314,46 @@ algorithm
e = simplify1(DAE.BINARY(DAE.RCONST(1.0),DAE.DIV(tp2),e3));
then
e;

// (a*b)/ a = b
case (_,DAE.DIV(ty = tp),DAE.BINARY(exp1 = e1,operator = DAE.MUL(ty = _),exp2 = e2),e3)
equation
true = Expression.expEqual(e1,e3);
tp2 = Expression.typeof(e2);
e = simplify1(e2);
then
e;

// (a*b)/ b = a
/* not yet tested
case (_,DAE.DIV(ty = tp),DAE.BINARY(exp1 = e1,operator = DAE.MUL(ty = _),exp2 = e2),e3)
equation
true = Expression.expEqual(e2,e3);
tp2 = Expression.typeof(e1);
e = simplify1(e1);
then
e;
*/

// (-a*b)/ a = -b
case (_,DAE.DIV(ty = tp),DAE.BINARY(exp1 = DAE.UNARY(operator = DAE.UMINUS(ty = _),exp = e1),operator = DAE.MUL(ty = _),exp2 = e2),e3)
equation
true = Expression.expEqual(e1,e3);
tp2 = Expression.typeof(e2);
e = simplify1(DAE.UNARY(DAE.UMINUS(tp2),e2));
then
e;

// (-a*b)/ b = -a
/* not yet tested
case (_,DAE.DIV(ty = tp),DAE.BINARY(exp1 = DAE.UNARY(operator = DAE.UMINUS(ty = _),exp = e1),operator = DAE.MUL(ty = _),exp2 = e2),e3)
equation
true = Expression.expEqual(e2,e3);
tp2 = Expression.typeof(e1);
e = simplify1(DAE.UNARY(DAE.UMINUS(tp2),e1));
then
e;
*/

// add with 0
case (_,DAE.ADD(ty = ty),e1,e2)
Expand Down

0 comments on commit 5ac85b6

Please sign in to comment.