﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
2099	constant evaluation of array is transposed	Jens Frenkel	Per Östlund	"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.
}}}
"	defect	closed	blocker	1.9.0	Frontend	trunk	fixed		Per Östlund Martin Sjölund Adrian Pop Lennart Ochel Willi Braun Vitalij Ruge
