Skip to content

Commit

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



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20724 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed May 21, 2014
1 parent 8d801b8 commit 6520d2f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -4031,6 +4031,29 @@ algorithm
equation
true = Expression.expEqual(e1,e2);
then Expression.makeBuiltinCall("sqrt",{e1},DAE.T_REAL_DEFAULT);
// x^y/x => x^(y-1)
case (_,DAE.DIV(ty = _),DAE.BINARY(e1,op1 as DAE.POW(ty), e2), e3,_,_)
equation
true = Expression.expEqual(e1,e3);
e4 = Expression.makeConstOne(ty);
e4 = DAE.BINARY(e2,DAE.SUB(ty), e4);
then DAE.BINARY(e1,op1, e4);
// x^y*z/x = x^(y-1)*z
case (_,DAE.DIV(ty = _),DAE.BINARY(DAE.BINARY(e1,op1 as DAE.POW(ty), e2),op2 as DAE.MUL(_),e5), e3,_,_)
equation
true = Expression.expEqual(e1,e3);
e4 = Expression.makeConstOne(ty);
e4 = DAE.BINARY(e2,DAE.SUB(ty), e4);
then DAE.BINARY(DAE.BINARY(e1,op1, e4),op2,e5);
//x/x^y => x^(1-y)
case (_,DAE.DIV(ty = _),e3, DAE.BINARY(e1,op1 as DAE.POW(ty), e2),_,_)
equation
true = Expression.expEqual(e1,e3);
e4 = Expression.makeConstOne(ty);
e4 = DAE.BINARY(e4,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 6520d2f

Please sign in to comment.