Skip to content

Commit

Permalink
added rule for
Browse files Browse the repository at this point in the history
 pow(x/y,-r) => pow(y/x,r)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20743 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed May 21, 2014
1 parent 8a26ac6 commit 269695c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -4066,13 +4066,20 @@ algorithm
e4 = Expression.makeConstOne(ty);
e4 = DAE.BINARY(e4,DAE.SUB(ty), e2);
then DAE.BINARY(e1,op1, e4);
//(x/y)^(-r) => (y/x)^r
case (_,op2 as DAE.POW(ty = _),DAE.BINARY(e1, op1 as DAE.DIV(_), e2), DAE.RCONST(r),_,_)
equation
true = realLt(r,0.0);
r = realNeg(r);
then DAE.BINARY(DAE.BINARY(e2,op1,e1),op2,DAE.RCONST(r));
//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,_)
equation
Expand Down

0 comments on commit 269695c

Please sign in to comment.