Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2532 closed defect (fixed)

Incorrect multilevel matrix slicing/indexing

Reported by: Malte Lenz Owned by: Adrian Pop
Priority: high Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: Cc:

Description

Instantiating Matrix:

model Vector
  Real x[2];
end Vector;

model Matrix
  Vector v[2];
equation
  v[:].x[:] = {{sin(time),cos(time)},{sin(time-0.5),cos(time-0.5)}};
end Matrix;

gives:

class Matrix
  Real v[1].x[1];
  Real v[1].x[2];
  Real v[2].x[1];
  Real v[2].x[2];
equation
  v[:].x[1,1] = sin(time);
  v[:].x[1,2] = cos(time);
  v[:].x[2,1] = sin(time + -0.5);
  v[:].x[2,2] = cos(time + -0.5);
end Matrix;

which is clearly not the correct indexing in the equations. This leads to a build/simulation failure.

Change History (3)

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

Owner: changed from somebody to Adrian Pop
Status: newassigned

comment:2 by Per Östlund, 11 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r18725.

comment:3 by jan.kokert@…, 11 years ago

Hi!

Now it's working perfectly!
Thank you for this fix!

class Matrix
  Real v[1].x[1];
  Real v[1].x[2];
  Real v[2].x[1];
  Real v[2].x[2];
equation
  v[1].x[1] = sin(time);
  v[1].x[2] = cos(time);
  v[2].x[1] = sin(time + -0.5);
  v[2].x[2] = cos(time + -0.5);
end Matrix;
Note: See TracTickets for help on using tickets.