Skip to content

Commit

Permalink
- added rule for sqrt(c*e) => c1*sqrt(e)
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19730 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed Mar 25, 2014
1 parent 77826cf commit 0b8cea1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -999,6 +999,13 @@ algorithm
case (DAE.CALL(path=Absyn.IDENT("sqrt"),expLst={DAE.CALL(path=Absyn.IDENT("sqrt"),expLst={e1})}))
then DAE.BINARY(e1,DAE.POW(DAE.T_REAL_DEFAULT),DAE.RCONST(0.25));

// sqrt(c*e) => c1*sqrt(e)
case DAE.CALL(path=Absyn.IDENT("sqrt"),expLst={DAE.BINARY(e1 as DAE.RCONST(r1),DAE.MUL(tp),e2)})
equation
e = Expression.makeBuiltinCall("sqrt",{e1},DAE.T_REAL_DEFAULT);
e3 = Expression.makeBuiltinCall("sqrt",{e2},DAE.T_REAL_DEFAULT);
then DAE.BINARY(e,DAE.MUL(tp),e3);

// exp(-log(x)) = 1/x
case (DAE.CALL(path=Absyn.IDENT("exp"),expLst={DAE.UNARY(DAE.UMINUS(ty = _), exp = DAE.CALL(path=Absyn.IDENT("log"),expLst={e1}))}))
then Expression.makeDiv(DAE.RCONST(1.0), e1);
Expand Down

0 comments on commit 0b8cea1

Please sign in to comment.