Skip to content

Commit

Permalink
Fix for #2587:
Browse files Browse the repository at this point in the history
- Added simplification rules -{e1, e2, ...} => {-e1, -e2, ...} and -[e1, e2, ...] => [-e1, e2, ...].
- Improved Static.elabMatrixCatTwoExp so it handles more cases.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19160 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Feb 18, 2014
1 parent 2fb07f4 commit 0ffd50d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -4542,6 +4542,8 @@ algorithm
Real r_1,r;
Boolean b1;
DAE.CallAttributes attr;
list<DAE.Exp> expl;
list<list<DAE.Exp>> mat;

// not true => false, not false => true
case (_,DAE.NOT(DAE.T_BOOL(varLst = _)),e1)
Expand Down Expand Up @@ -4606,6 +4608,19 @@ algorithm
// -semiLinear(-x,sb,sa) = semiLinear(x,sa,sb)
case (_,DAE.UMINUS(ty = _),DAE.CALL(path=Absyn.IDENT("semiLinear"),expLst={DAE.UNARY(exp=e1),e2,e3},attr=attr))
then DAE.CALL(Absyn.IDENT("semiLinear"),{e1,e3,e2},attr);

case (_, DAE.UMINUS_ARR(ty = _), DAE.ARRAY(ty1, b1, expl))
equation
expl = List.map(expl, Expression.negate);
then
DAE.ARRAY(ty1, b1, expl);

case (_, DAE.UMINUS_ARR(ty = _), DAE.MATRIX(ty1, i, mat))
equation
mat = List.mapList(mat, Expression.negate);
then
DAE.MATRIX(ty1, i, mat);

else origExp;
end matchcontinue;
end simplifyUnary;
Expand Down
2 changes: 2 additions & 0 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -2773,6 +2773,8 @@ algorithm
list<DAE.Exp> expl;
case (DAE.ARRAY(array = expl))
equation
expl = ExpressionSimplify.simplifyList(expl, {});
expl = List.map(expl, Expression.matrixToArray);
res = elabMatrixCatTwo(expl);
then
res;
Expand Down

0 comments on commit 0ffd50d

Please sign in to comment.