Skip to content

Commit

Permalink
- fixes from static analysis
Browse files Browse the repository at this point in the history
- uncomment diff(atan2(y,0)) rule  



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21710 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed Aug 1, 2014
1 parent bd4ed22 commit 7a48a1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 14 additions & 3 deletions Compiler/BackEnd/Differentiate.mo
Expand Up @@ -1479,14 +1479,16 @@ algorithm
//print("\nresults to exp: " +& s1);
then (res, funcs);

/*
// simplication done in ExpressionSimply
// differentiate builtin calls with N arguments with match
// der(arctan2(y,0)) = der(sign(y)*pi/2) = 0
case (DAE.CALL(path=Absyn.IDENT("atan2"),attr=DAE.CALL_ATTR(builtin=true),expLst={_,e1 as DAE.RCONST(r)}), _, _, _, _)
equation
0.0 = r;
0.0 = r; // match -> matchcontinue?
then
(e1, inFunctionTree);

*/
// differentiate builtin calls with N arguments as match
case (DAE.CALL(path=Absyn.IDENT(name),attr=(attr as DAE.CALL_ATTR(builtin=true)),expLst= (expl as (_::_::_))), _, _, _, _)
equation
Expand Down Expand Up @@ -1965,7 +1967,16 @@ algorithm
DAE.MUL(tp),de1);
then
(e, funcs);

// x^i
case (DAE.BINARY(exp1 = e1,operator = DAE.POW(tp),exp2 = (e2 as DAE.ICONST(integer = i))), _, _, _, _)
equation
(de1, funcs) = differentiateExp(e1, inDiffwrtCref, inInputData, inDiffType, inFunctionTree);
i = i - 1;
e = DAE.BINARY(DAE.BINARY(e2,DAE.MUL(tp),
DAE.BINARY(e1,DAE.POW(tp),DAE.ICONST(i))),
DAE.MUL(tp),de1);
then
(e, funcs);
// der(0^x) = 0
case (DAE.BINARY(exp1 = (DAE.RCONST(real=0.0)),operator = DAE.POW(tp),exp2 = _), _, _, _, _)
equation
Expand Down
6 changes: 1 addition & 5 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -2238,7 +2238,7 @@ algorithm
DAE.ARRAY(ty, true, expl1);

// Vector-matrix multiplication, c[m] = a[n] * b[n, m].
case (DAE.ARRAY(ty = DAE.T_ARRAY(dims = {_}), array = expl1),
case (DAE.ARRAY(ty = DAE.T_ARRAY(dims = {_}), array = _),
DAE.ARRAY(ty = DAE.T_ARRAY(ty, {m, _}, tp), array = expl2))
equation
// c[i] = a * b[:, i] for i in 1:m
Expand Down Expand Up @@ -4303,7 +4303,6 @@ algorithm
DAE.BINARY(e_4,DAE.MUL(_),e_5),_,_,
_,_,_,true /*e2==e4==e_3==e_6*/,_,false /*isConst(e2==e_3)*/,_,true /*op2==op3*/)
equation
ty = Expression.typeof(e_1);

true = Expression.operatorEqual(op1,DAE.SUB(ty)) or
Expression.operatorEqual(op1,DAE.ADD(ty));
Expand All @@ -4325,7 +4324,6 @@ algorithm
false = Expression.isConst(e_2);
true = Expression.expEqual(e_2,e_6);
true = Expression.operatorEqual(op2,op3);
ty = Expression.typeof(e_1);

true = Expression.operatorEqual(op1,DAE.SUB(ty)) or
Expression.operatorEqual(op1,DAE.ADD(ty));
Expand All @@ -4347,7 +4345,6 @@ algorithm
false = Expression.isConst(e_2);
true = Expression.expEqual(e_2,e_5);
true = Expression.operatorEqual(op2,op3);
ty = Expression.typeof(e_1);

true = Expression.operatorEqual(op1,DAE.SUB(ty)) or
Expression.operatorEqual(op1,DAE.ADD(ty));
Expand All @@ -4368,7 +4365,6 @@ algorithm
equation
true = Expression.expEqual(e_3,e_5);
true = Expression.operatorEqual(op2,op3);
ty = Expression.typeof(e1);

true = Expression.operatorEqual(op1,DAE.SUB(ty)) or
Expression.operatorEqual(op1,DAE.ADD(ty));
Expand Down

0 comments on commit 7a48a1e

Please sign in to comment.