Opened 12 years ago

Closed 12 years ago

#2099 closed defect (fixed)

constant evaluation of array is transposed

Reported by: jfrenkel Owned by: perost
Priority: blocker Milestone: 1.9.0
Component: Frontend Version: trunk
Keywords: Cc: perost, sjoelund.se, adrpo, lochel, wbraun, vitalij

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 Changed 12 years ago by lochel

  • Cc vitalij added

comment:2 Changed 12 years ago by perost

  • Owner changed from somebody to perost
  • Status changed from new to accepted

comment:3 Changed 12 years ago by perost

  • Resolution set to fixed
  • Status changed from accepted to closed

Fixed in r15472.

Note: See TracTickets for help on using tickets.