Skip to content

Commit

Permalink
added some rules
Browse files Browse the repository at this point in the history
- pow(x,y)*pow(x,z) = pow(x,y+z)
- pow(x,y)*x = pow(x,y+1)
- pow(x,y)/pow(x,z) = pow(x,y-z)



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20732 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed May 21, 2014
1 parent e49513a commit 9afe9f3
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -3655,6 +3655,20 @@ algorithm
true = Expression.expEqual(e1,e2);
then
DAE.BINARY(e1,DAE.POW(DAE.T_REAL_DEFAULT),DAE.BINARY(e,DAE.ADD(DAE.T_REAL_DEFAULT),DAE.RCONST(0.5)));
// x^y*x^z => x^(y+z)
case (DAE.MUL(ty=_),DAE.BINARY(e1,op1 as DAE.POW(tp),e2),DAE.BINARY(e3, DAE.POW(_),e4))
equation
true = Expression.expEqual(e1,e3);
then
DAE.BINARY(e1,op1,DAE.BINARY(e2,DAE.ADD(tp),e4));
// x*x^y => x^(y+1)
case (DAE.MUL(ty=_),e1,DAE.BINARY(e3, op1 as DAE.POW(tp),e4))
equation
true = Expression.expEqual(e1,e3);
e = Expression.makeConstOne(tp);
then
DAE.BINARY(e1,op1,DAE.BINARY(e,DAE.ADD(tp),e4));

end matchcontinue;
end simplifyBinaryCommutativeWork;

Expand Down Expand Up @@ -4052,8 +4066,12 @@ algorithm
e4 = Expression.makeConstOne(ty);
e4 = DAE.BINARY(e4,DAE.SUB(ty), e2);
then DAE.BINARY(e1,op1, e4);


//x^y/x^z => x^(y-z)
case (_,DAE.DIV(ty = _),DAE.BINARY(e3,DAE.POW(_),e5), DAE.BINARY(e1,op1 as DAE.POW(ty), e2),_,_)
equation
true = Expression.expEqual(e1,e3);
e4 = DAE.BINARY(e5,DAE.SUB(ty), e2);
then DAE.BINARY(e1,op1, e4);

// 1 ^ e => 1
case (_,DAE.POW(ty = _),e1,_,true,_)
Expand Down

0 comments on commit 9afe9f3

Please sign in to comment.