Skip to content

Commit

Permalink
- guard again c<0 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@19732 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed Mar 25, 2014
1 parent 0b8cea1 commit c11a138
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -1002,6 +1002,7 @@ algorithm
// 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
true = r1 >=. 0.0;
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);
Expand Down Expand Up @@ -3886,7 +3887,15 @@ algorithm
Expression.operatorEqual(op2,DAE.MUL(ty));
res = DAE.BINARY(e1, op2, e2);
then Expression.makeBuiltinCall("abs",{res},ty);

/*
// e1 / exp(e2) => e1*exp(-e2)
case(_,DAE.DIV(ty),e1,DAE.CALL(path=Absyn.IDENT("exp"),expLst={e2}),_,_)
equation
e = DAE.UNARY(DAE.UMINUS(ty),e2);
e3 = Expression.makeBuiltinCall("exp",{e},ty);
res = DAE.BINARY(e,DAE.MUL(ty),e3);
then res;
*/
// exp(e1) * exp(e2) => exp(e1 + e2)
case(_,DAE.MUL(ty),DAE.CALL(path=Absyn.IDENT("exp"),expLst={e1}),DAE.CALL(path=Absyn.IDENT("exp"),expLst={e2}),_,_)
equation
Expand Down

0 comments on commit c11a138

Please sign in to comment.