Skip to content

Commit

Permalink
- added rule for a*x*c + d*x*e => x*(a*c + d*e)
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21767 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed Aug 6, 2014
1 parent aeaea6d commit 1ab6982
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -4112,7 +4112,19 @@ algorithm
e = DAE.BINARY(e2,op1,e5);
res = DAE.BINARY(e3,op1,e6);
then DAE.IFEXP(e1,e,res);


// a*x op2 b op1 c*x op3 d
// x *(a op2 b op1 c op3 d)
case (_,op1,DAE.BINARY(e1,oper as DAE.MUL(ty),DAE.BINARY(e2,op2,e3)), DAE.BINARY(e4,DAE.MUL(_),DAE.BINARY(e5,op3,e6)),false,false)
equation
true = Expression.operatorEqual(op1,DAE.SUB(ty)) or
Expression.operatorEqual(op1,DAE.ADD(ty));
true = Expression.operatorEqual(op2,DAE.MUL(ty)) or
Expression.operatorEqual(op2,DAE.DIV(ty));
true = Expression.operatorEqual(op3,DAE.MUL(ty)) or
Expression.operatorEqual(op3,DAE.DIV(ty));
true = Expression.expEqual(e2,e5);
then DAE.BINARY(e5, oper, DAE.BINARY(DAE.BINARY(e1,op2,e3),op1,DAE.BINARY(e4,op3,e6)));

// (a1a2...an)^e2 => a1^e2a2^e2..an^e2
case (_,DAE.POW(ty = _),e1,e2,_,true)
Expand Down

0 comments on commit 1ab6982

Please sign in to comment.