﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
2469	Unrolling array expressions	Christian Schubert	Per Östlund	"Hi,

Bruno has written a great library for simulating flexible bodies. Unfortunately, OMC is not able to handle it because of the extensive use of multi dimensional matrices in the code.

I created a small example to illustrate the problem:
{{{
model FemPackage_Test
  constant Integer N = 10;
  constant Integer M = 30;
  parameter Real A[N,N] = identity(N);
  parameter Real B[N,N,M] = ones(N,N,M);
  Real q[M](each start = 1, each fixed=true);
  Real C[N,N];
equation
  C = A + sum(B[:,:,i]*q[i] for i in 1:M);
  der(q) = -q;
end FemPackage_Test;
}}}
Since every expression is rolled out in the frontend, the expressions become very large and thus memory consumption as well as flattening time are enormous. Life sized models have many such expressions with much larger dimensions.

My question is how we can circumvent this? All the multidimensional matrices are known constants, so it is not required to unroll them for matching in the backend. 
Would it be possible to not unroll expressions above a 'certain size'?

It would be great if that library could be used with OpenModelica!

PS: This model does not compile with OpenModelica:
{{{
expected 'const struct real_array_t *' but argument is of type 'modelica_real *'
}}}"	discussion	closed	high	2.0.0	New Instantiation	trunk	fixed	Unrolling array expressions	Bruno Scaglioni Per Östlund Martin Sjölund gianni.ferretti@…
