- Index
- » Developer
- » OpenModelica development
- » Problem using function pre() in...
Problem using function pre() in discrete matrix
Problem using function pre() in discrete matrix
Hi,
I have a model that in an event needs to use the previous values of a discrete matrix. However when a try to call the function pre() in a for loop containing an element of a two-dimensional array (with size [nRows,nCols]), I get the following error in OMshell, when translating:
[SimCodeC.tpl:5687:11-5687:11:writable] Error: Template error: Code generation does not support pre( matrix.value[i,j] )
I am using openmodelica 1.8.0 revision 10787.
The same model works in OM when scalar variables and vectors (1-dimensional array) are used instead of matrices.
The same model works with two-dimensional arrays in Dymola 6.1 and 2012.
Could this error be a limitation of this version of OpenModelica?
Thanks in Advance,
Erick
Re: Problem using function pre() in discrete matrix
Is this for-loop in an algorithm or equation section?
- sjoelund.se
- 1700 Posts
Re: Problem using function pre() in discrete matrix
Fixed in r10892
Code:
loadString("model PreMatrix
Integer x[2,2] = integer(time*fill(1,2,2));
Integer y[2,2];
algorithm
for i in 1:size(x,1),j in 1:size(x,2) loop
y[i,j] := pre(x[i,j]);
end for;
end PreMatrix;","PreMatrix.mo");getErrorString();
buildModel(PreMatrix);getErrorString();
Generates:
Code:
/*#modelicaLine [a.mo:6:5-6:26]*/#
integer_array_create(&tmp0, ((modelica_integer*)&($Py)), 2, 2, 2);
(*integer_array_element_addr(&tmp0, 2, (modelica_integer)$Pi, (modelica_integer)$Pj)) = *(&$P$PRE$Px + ((modelica_integer)$Pi*2) + ((modelica_integer)$Pj));
/*#endModelicaLine*/
And yes I know the assignment code is damn stupid...
- sjoelund.se
- 1700 Posts
- Index
- » Developer
- » OpenModelica development
- » Problem using function pre() in...