@@ -4689,8 +4689,8 @@ template daeExpRange(Exp exp, Context context, Text &preExp /*BUFP*/,
46894689 let tmp = tempDecl('multi_array<<%ty_str%>,1>', &varDecls /*BUFD*/)
46904690 let step_exp = match step case SOME(stepExp) then daeExp(stepExp, context, &preExp, &varDecls,simCode) else "1"
46914691 let &preExp += 'int num_elems =(<%stop_exp%>-<%start_exp%>)/<%step_exp%>+1;
4692- <%tmp%>.reindex(1 );
4693- <%tmp%>.resize((boost::extents[num_elems]) );
4692+ <%tmp%>.resize((boost::extents[num_elems]) );
4693+ <%tmp%>.reindex(1 );
46944694 for(int i= 1;i<=num_elems;i++)
46954695 <%tmp%>[i] =<%start_exp%>+(i-1)*<%step_exp%>;
46964696 '
@@ -4800,12 +4800,19 @@ template daeExpReduction(Exp exp, Context context, Text &preExp /*BUFP*/,
48004800
48014801 >>
48024802 let loopTail = ' }'
4803-
4803+ let loopvarassign =
4804+ match typeof(iter.exp)
4805+ case ty as T_ARRAY(__) then
4806+ ' assign_array( <%loopVar%>,<%rangeExp%>);'
4807+ else
4808+ ' <%loopVar%> = <%rangeExp%>;'
4809+ end match
48044810 let &preExp += <<
48054811 {
48064812 <% &tmpVarDecls%>
48074813 <% &rangeExpPre%>
4808- <% loopVar%> = <% rangeExp%> ;
4814+ <% loopvarassign%>
4815+
48094816 <% if firstIndex then ' <%firstIndex%> = 1;' %>
48104817 <% firstValue%>
48114818 <% if resTail then ' <%resTail%> = &<%res%>;' %>
@@ -6081,9 +6088,10 @@ case ARRAY(__) then
60816088 arrayVar
60826089 else
60836090 match typeof(exp)
6084- case T_ARRAY(dims=dims) then
6091+ case ty as T_ARRAY(dims=dims) then
60856092 let resVarType = 'multi_array<<%expTypeShort(ty)%>,<%listLength(dims)%>>'
60866093 let resVar = tempDecl(resVarType, &varDecls /*BUFD*/)
6094+
60876095 resVar
60886096 else
60896097 let resVarType = expTypeFlag(typeof(exp), 2)
0 commit comments