Skip to content

Commit 9afe9f3

Browse files
author
Vitalij Ruge
committed
added some rules
- 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
1 parent e49513a commit 9afe9f3

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Compiler/FrontEnd/ExpressionSimplify.mo

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,6 +3655,20 @@ algorithm
36553655
true = Expression.expEqual(e1,e2);
36563656
then
36573657
DAE.BINARY(e1,DAE.POW(DAE.T_REAL_DEFAULT),DAE.BINARY(e,DAE.ADD(DAE.T_REAL_DEFAULT),DAE.RCONST(0.5)));
3658+
// x^y*x^z => x^(y+z)
3659+
case (DAE.MUL(ty=_),DAE.BINARY(e1,op1 as DAE.POW(tp),e2),DAE.BINARY(e3, DAE.POW(_),e4))
3660+
equation
3661+
true = Expression.expEqual(e1,e3);
3662+
then
3663+
DAE.BINARY(e1,op1,DAE.BINARY(e2,DAE.ADD(tp),e4));
3664+
// x*x^y => x^(y+1)
3665+
case (DAE.MUL(ty=_),e1,DAE.BINARY(e3, op1 as DAE.POW(tp),e4))
3666+
equation
3667+
true = Expression.expEqual(e1,e3);
3668+
e = Expression.makeConstOne(tp);
3669+
then
3670+
DAE.BINARY(e1,op1,DAE.BINARY(e,DAE.ADD(tp),e4));
3671+
36583672
end matchcontinue;
36593673
end simplifyBinaryCommutativeWork;
36603674

@@ -4052,8 +4066,12 @@ algorithm
40524066
e4 = Expression.makeConstOne(ty);
40534067
e4 = DAE.BINARY(e4,DAE.SUB(ty), e2);
40544068
then DAE.BINARY(e1,op1, e4);
4055-
4056-
4069+
//x^y/x^z => x^(y-z)
4070+
case (_,DAE.DIV(ty = _),DAE.BINARY(e3,DAE.POW(_),e5), DAE.BINARY(e1,op1 as DAE.POW(ty), e2),_,_)
4071+
equation
4072+
true = Expression.expEqual(e1,e3);
4073+
e4 = DAE.BINARY(e5,DAE.SUB(ty), e2);
4074+
then DAE.BINARY(e1,op1, e4);
40574075

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

0 commit comments

Comments
 (0)