Skip to content

Commit

Permalink
improved simplifyAddMakeMul
Browse files Browse the repository at this point in the history
  • Loading branch information
vruge committed Dec 19, 2015
1 parent ed47290 commit dd2007d
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -2801,7 +2801,7 @@ algorithm
coeff := coeff + coeff2;
outTplExpRealLst := (e, coeff) :: outTplExpRealLst;
end while;
outTplExpRealLst := listReverse(outTplExpRealLst);
//outTplExpRealLst := listReverse(outTplExpRealLst);
end simplifyAddJoinTerms;

protected function simplifyAddJoinTermsFind
Expand Down Expand Up @@ -2841,39 +2841,36 @@ protected function simplifyAddMakeMul
Makes multiplications of each element
in the list, except for coefficient 1.0"
input list<tuple<DAE.Exp, Real>> inTplExpRealLst;
output list<DAE.Exp> outExpLst;
output list<DAE.Exp> outExpLst = {};
protected
tuple<DAE.Exp, Real> tplExpReal;
algorithm
outExpLst := matchcontinue (inTplExpRealLst)
for tplExpReal in inTplExpRealLst loop

outExpLst := matchcontinue (tplExpReal)
local
list<DAE.Exp> res;
DAE.Exp e;
Real r;
list<tuple<DAE.Exp, Real>> xs;
Integer tmpInt;

case ({}) then {};

case (((e,r) :: xs))
equation
(r == 1.0) = true;
res = simplifyAddMakeMul(xs);
case (e,r)
guard (r == 1.0)
then
(e :: res);
(e :: outExpLst);

case (((e,r) :: xs))
case (e,r)
equation
DAE.T_INTEGER() = Expression.typeof(e);
res = simplifyAddMakeMul(xs);
tmpInt = realInt(r);
then
(DAE.BINARY(DAE.ICONST(tmpInt),DAE.MUL(DAE.T_INTEGER_DEFAULT),e) :: res);
(DAE.BINARY(DAE.ICONST(tmpInt),DAE.MUL(DAE.T_INTEGER_DEFAULT),e) :: outExpLst);

case (((e,r) :: xs))
equation
res = simplifyAddMakeMul(xs);
case (e,r)
then
(DAE.BINARY(DAE.RCONST(r),DAE.MUL(DAE.T_REAL_DEFAULT),e) :: res);
end matchcontinue;
(DAE.BINARY(DAE.RCONST(r),DAE.MUL(DAE.T_REAL_DEFAULT),e) :: outExpLst);
end matchcontinue;

end for;
end simplifyAddMakeMul;

protected function simplifyBinaryAddCoeff2
Expand Down

0 comments on commit dd2007d

Please sign in to comment.