This repository was archived by the owner on May 18, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -574,6 +574,13 @@ public
574574 end match;
575575 end realValue;
576576
577+ function integerValue
578+ input Expression exp;
579+ output Integer value;
580+ algorithm
581+ INTEGER (value= value) := exp;
582+ end integerValue;
583+
577584 function applySubscripts
578585 input list< Subscript > subscripts;
579586 input output Expression exp;
Original file line number Diff line number Diff line change @@ -155,7 +155,8 @@ protected
155155 Integer i1, i2;
156156 Real r1, r2;
157157 Boolean b1, b2;
158- list< Expression > expl = {};
158+ list< Expression > expl = {}, expl1, expl2;
159+ Type ty;
159160
160161 import NFOperator.Op ;
161162algorithm
@@ -193,6 +194,28 @@ algorithm
193194 case Op . SUB then Expression . REAL (r1 - r2);
194195 case Op . MUL then Expression . REAL (r1 * r2);
195196 case Op . DIV then Expression . REAL (r1 / r2);
197+ case Op . POW then Expression . REAL (r1 ^ r2);
198+ else exp;
199+ end match;
200+
201+ case Expression . BINARY (exp1= Expression . ARRAY (ty= ty, elements= expl1), exp2= Expression . ARRAY (elements= expl2))
202+ then match (exp. operator. op, Type . elementType(ty))
203+ case (Op . SCALAR_PRODUCT , Type . REAL ())
204+ algorithm
205+ try
206+ exp1 := Expression . REAL (sum(Expression . realValue(e1)* Expression . realValue(e2) threaded for e1 in expl1, e2 in expl2));
207+ else
208+ exp1 := exp;
209+ end try ;
210+ then exp1;
211+ case (Op . SCALAR_PRODUCT , Type . INTEGER ())
212+ algorithm
213+ try
214+ exp1 := Expression . INTEGER (sum(Expression . integerValue(e1)* Expression . integerValue(e2) threaded for e1 in expl1, e2 in expl2));
215+ else
216+ exp1 := exp;
217+ end try ;
218+ then exp1;
196219 else exp;
197220 end match;
198221
You can’t perform that action at this time.
0 commit comments