Opened 14 years ago

Closed 12 years ago

#1415 closed defect (fixed)

array bindings need to be handled better in the compiler

Reported by: Martin Sjölund Owned by: Martin Sjölund
Priority: high Milestone: 1.9.0
Component: Backend Version:
Keywords: Cc: Martin Sjölund, AlexeyLebedev, Frenkel, TUD, Willi Braun

Description (last modified by Martin Sjölund)

  class ArrayCall
    function fn
      input Real r;
      output Real array[10];
    algorithm
      array := 1:10.0;
      array := cos(r*array);
    end fn;
    Real x[10] = fn(time);
  end ArrayCall;

Either we do common subexpression elimination in the backend or keep the arrays non-expanded. Common subexpression elimination would of course be preferrable as then we could do things like:

class ArrayCall
  Real x[10] = fn(time);
  Real y[10] = fn(time)*2;
  Real z[10] = fn(time)*3;
end ArrayCall;

And only call fn once. We probably need to introduce temporary variables to deal with duplicated function calls.

Change History (3)

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

The binding x = fn(time) could be moved into the equation-section, which avoids some of these issues.

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

Cc: Frenkel TUD added; Jens Frenkel removed
Component: Backend
Description: modified (diff)

comment:3 by Martin Sjölund, 12 years ago

Milestone: 1.9.0
Resolution: fixed
Status: newclosed

We now move the binding into the equation section.

Note: See TracTickets for help on using tickets.