﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
1368	Zero crossings in algorithms in for loops are generated wrong	Adrian Pop	Adrian Pop	"This is one of the issues with codegen for {{{Modelica.Electrical.Digital.Examples.Multiplexer}}}.
{{{
model X
 parameter Integer n = 4;
 parameter Real x[n] = {1, 2, 3, 4};
 Real y[n];
algorithm
 for i in 1:n loop
  y[i] := if time > x[i] then x[i] else i;
 end for;
end X;
}}}
gets you in the C code:
{{{
  array_alloc_scalar_real_array(&tmp10, 4, (modelica_real)$Px$lB1$rB, (modelica_real)$Px$lB2$rB, (modelica_real)$Px$lB3$rB, (modelica_real)$Px$lB4$rB);
  ZEROCROSSING(0, Greater(time, (tmp10[(modelica_integer)$Pi])));
}}}
which is obviously wrong, you should have 4 zero crossings.\\
I think that BackendDAECreate.collectZeroCrossings should expand for loops \\
in algorithms and then collect zero crossings. However, if the for loop range\\
is not a parameter, and you cannot expand the for loop, then i don't know how\\
to deal with this. Any suggestions??"	defect	closed	high	White December	Simulation Code Generation		fixed		Adrian Pop Adrian Pop Jens Frenkel Willi Braun
