Opened 12 years ago

Closed 12 years ago

#2099 closed defect (fixed)

constant evaluation of array is transposed

Reported by: Jens Frenkel Owned by: Per Östlund
Priority: blocker Milestone: 1.9.0
Component: Frontend Version: trunk
Keywords: Cc: Per Östlund, Martin Sjölund, Adrian Pop, Lennart Ochel, Willi Braun, Vitalij Ruge

Description

Hi,

if the folowing Model is instantiated

model ConstLinearSystem2
  constant Real A[2,2] = {{0.0,  1.0},
                          {2.0,  0.0}};
  constant Real b[2] = {1.0, 2.0};
  Real x[2];
equation
  A*x = b;
end ConstLinearSystem2;

you get the equations

  x[2] = 1.0;
  2.0 * x[1] = 2.0;

Which is fine, but if the following Model is instantiated

model ConstLinearSystem4
  constant Real A[4,4] = {{1.0,  0.0, 0.0, 1.0},
                          {0.0,  1.0, 2.0, 0.0}, 
                          {0.0,  3.0, 1.0, 0.0}, 
                          {4.0,  0.0, 0.0, 4.0}};
  constant Real b[4] = {1.0, 2.0, 3.0, 4.0};
  Real x[4];
equation
  A*x = b;
end ConstLinearSystem4;

you get the equations

  x[1] + 4.0 * x[4] = 1.0;
  x[2] + 3.0 * x[3] = 2.0;
  2.0 * x[2] + x[3] = 3.0;
  x[1] + 4.0 * x[4] = 4.0;

whis is obviously wrong because it should be

  x[1] + x[4] = 1.0;
  x[2] + 2.0 * x[3] = 2.0;
  3.0 * x[2] + x[3] = 3.0;
  4.0 * x[1] + 4.0 * x[4] = 4.0;

and it become even wors if you try to transpose A

  transpose(A)*x = b;

you end up with the following error Message

Error processing file: ConstLinearSystem.mo
[D:\Programming\OPENMODELICA\CompilerStages\Models\Academic\ConstLinearSystem.mo
:40:3-40:21:writable] Error: Got type mismatch error, but matching types Real[4]
.
This is a ***COMPILER BUG***, please report it to https://trac.openmodelica.org/
OpenModelica.
Error: Error occurred while flattening model ConstLinearSystem4

# Error encountered! Exiting...
# Please check the error message and the flags.

Change History (3)

comment:1 by Lennart Ochel, 12 years ago

Cc: Vitalij Ruge added

comment:2 by Per Östlund, 12 years ago

Owner: changed from somebody to Per Östlund
Status: newaccepted

comment:3 by Per Östlund, 12 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in r15472.

Note: See TracTickets for help on using tickets.