Opened 13 years ago

Last modified 13 years ago

#1674 closed defect (fixed)

function sum with reductions does not work: {sum(myArray[1:i]) for i in 1:dimensions}

Reported by: Fritz Zaversky Owned by: Fritz Zaversky
Priority: high Milestone:
Component: Version:
Keywords: Cc: Fritz Zaversky,

Description

{{{model OMtest

parameter Integer dimensions = 5;
parameter Real myArray[dimensions] = {1,2,3,4,5};
parameter Real mySumArray[dimensions] = {sum(myArray[1:i]) for i in 1:dimensions};

end OMtest;}}}

following error:

{{{[SimCodeC.tpl:5647:11-5647:11:writable] Error: Template error: ASUB_EASY_CASE 1:1
[SimCodeC.tpl:5647:11-5647:11:writable] Error: Template error: ASUB_EASY_CASE 1:2
[SimCodeC.tpl:5647:11-5647:11:writable] Error: Template error: ASUB_EASY_CASE 1:3
[SimCodeC.tpl:5647:11-5647:11:writable] Error: Template error: ASUB_EASY_CASE 1:4}}}

Change History (2)

comment:1 by Martin Sjölund, 13 years ago

Interestingly, the following also does not work:
{{{model OMtest

parameter Integer dimensions = 5;
parameter Integer d = 3;
parameter Real myArray[dimensions] = {1,2,3,4,5};
parameter Real mySumArray[dimensions] = {sum(myArray[1:d]) for i in 1:dimensions};

end OMtest;}}}

comment:2 by Martin Sjölund, 13 years ago

Fixed in r10870 (see SCM commits)

Note: See TracTickets for help on using tickets.