@@ -1573,6 +1573,27 @@ algorithm
15731573 (exp_2, funcs) = differentiateExp(exp_1, inDiffwrtCref, inInputData, inDiffType, inFuncs);
15741574 then
15751575 (exp_2, funcs);
1576+
1577+ case ("floor" ,_,_,_,_,_)
1578+ equation
1579+ tp = Expression . typeof(exp);
1580+ (exp_1, _) = Expression . makeZeroExpression(Expression . arrayDimension(tp));
1581+ then
1582+ (exp_1, inFuncs);
1583+
1584+ case ("ceil" ,_,_,_,_,_)
1585+ equation
1586+ tp = Expression . typeof(exp);
1587+ (exp_1, _) = Expression . makeZeroExpression(Expression . arrayDimension(tp));
1588+ then
1589+ (exp_1, inFuncs);
1590+
1591+ case ("integer" ,_,_,_,_,_)
1592+ equation
1593+ tp = Expression . typeof(exp);
1594+ (exp_1, _) = Expression . makeZeroExpression(Expression . arrayDimension(tp));
1595+ then
1596+ (exp_1, inFuncs);
15761597 end match;
15771598end differentiateCallExp1Arg;
15781599
@@ -1607,7 +1628,7 @@ protected function differentiateCallExpNArg "
16071628algorithm
16081629 (outDiffedExp,outFunctionTree) := match(name,inExpl,inAttr,inDiffwrtCref,inInputData,inDiffType,inFunctionTree)
16091630 local
1610- DAE . Exp e, e1, e2, cond;
1631+ DAE . Exp e, e1, e2, cond, etmp ;
16111632 DAE . Exp res, res1, res2;
16121633 list< DAE . Exp > expl, dexpl;
16131634 DAE . Type tp;
@@ -1685,6 +1706,31 @@ algorithm
16851706 then
16861707 (DAE . IFEXP (DAE . CALL (Absyn . IDENT ("noEvent" ),{DAE . RELATION (e1,DAE . LESS (tp),e2,-1 ,NONE ())},DAE . callAttrBuiltinBool), res1, res2), funcs);
16871708
1709+ // diff(div(e1,e2)) = diff(if noEvent(e1 > 0) then floor(e1/e2) else ceil(e1/e2)) = 0.0;
1710+ case ("div" , {e1,e2}, DAE . CALL_ATTR (ty= tp), _, _, _, _)
1711+ equation
1712+ (res1, _) = Expression . makeZeroExpression(Expression . arrayDimension(tp));
1713+ then
1714+ (res1, inFunctionTree);
1715+
1716+ // diff(mod(e1,e2)) = diff(e1 - e2*floor(e1/e2))
1717+ case ("mod" , {e1,e2}, DAE . CALL_ATTR (ty= tp), _, _, _, _)
1718+ equation
1719+ etmp = Expression . makePureBuiltinCall("floor" , {DAE . BINARY (e1, DAE . DIV (tp), e2)}, tp);
1720+ e = DAE . BINARY (e1, DAE . SUB (tp), DAE . BINARY (e2, DAE . MUL (tp), etmp));
1721+ (res1, funcs) = differentiateExp(e, inDiffwrtCref, inInputData, inDiffType, inFunctionTree);
1722+ then
1723+ (res1, funcs);
1724+
1725+ // diff(rem(e1,e2)) = diff(e1 -div(e1,e2)*e2)
1726+ case ("rem" , {e1,e2}, DAE . CALL_ATTR (ty= tp), _, _, _, _)
1727+ equation
1728+ etmp = Expression . makePureBuiltinCall("div" , {e1, e2}, tp);
1729+ e = DAE . BINARY (e1, DAE . SUB (tp), DAE . BINARY (e2, DAE . MUL (tp), etmp));
1730+ (res1, funcs) = differentiateExp(e1, inDiffwrtCref, inInputData, inDiffType, inFunctionTree);
1731+ then
1732+ (res1, funcs);
1733+
16881734 end match;
16891735end differentiateCallExpNArg;
16901736
0 commit comments