Opened 14 years ago
Last modified 13 years ago
#1372 closed defect (fixed)
instantiation of example using Modelica.Math.Matrices.norm fails
Reported by: | Peter Aronsson | Owned by: | Peter Aronsson |
---|---|---|---|
Priority: | blocker | Milestone: | White December |
Component: | Version: | ||
Keywords: | Cc: | Peter Aronsson, Adrian Pop |
Description
This model fails to instantiate (using instantiateModel in a mos-file).
NOTE: this must be fixed also on OpenModelica-1.5.1-Maintenance branch!
{{{ model Test_Math_Matrices_norm
parameter Real A[:,:]=[1,10,1000;0.01,0,10;0.005,0.01,10];
Real x1;
Real x2;
Real x3;
Real x4;
equation
x1=Modelica.Math.Matrices.norm(A, 1) "Should return 1020";
x2=Modelica.Math.Matrices.norm(A, 2) "Should return 1000.15";
x3=Modelica.Math.Matrices.norm(A, Modelica.Constants.inf) "Should return 1011";
x4=Modelica.Math.Matrices.norm(A) "Should return 1000.15";
end Test_Math_Matrices_norm;}}}
It gives this error message:
{{{ instantiateDaeFunction failed for Modelica.Math.Matrices.norm in scope: Test_Math_Matrices_norm
}}}
Attachments (2)
Change History (5)
by , 14 years ago
Attachment: | MathTest.mo added |
---|
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Per looked a bit into it and here are his comments:
The problem is that elabBuiltinAbs fails, because elabCallArgs2 tries to call vectorizeCall which fails because it doesn't know how large abs(A[:,i]) is. This is of course because we don't instantiate functions with bindings on the input parameters. I tried to allow elaboration of abs to simply generate a call to abs with the vector as argument, but that just caused a lot of other issues with other functions that couldn't handle unknown dimensions. I think the "right" solution would be to not vectorize calls inside functions when we instantiate them, but to do that when we elaborate a call to the function and knows the sizes of the input arguments (if we really need to vectorize calls at all).
I will look into this bug myself.
comment:3 by , 14 years ago
I think i fixed this issue, but you might have to handle more things in your back-end:
abs/sum/max/min of unknown array size. Please check and let me know.
I also added a test for it, see SCM Commits.
comment:4 by , 13 years ago
No comments from MathCore for over half a year. I'm assuming it was good enough. I added the model as a regression test in OpenModelica and fixed some of the remaining codegen issues we had for this.
The OM 1.6.0 error message has more information (too much, but that is only because builtin operators are special) :
{{{Error processing file: a.mo
Users/martin/dev/trunk/build//lib/omlibrary/msl31/Modelica/Math/package.mo:439:9-439:49:writable Error: No matching function found for abs in component <NO COMPONENT>
candidates are function(x:Integer) => Integer
Users/martin/dev/trunk/build//lib/omlibrary/msl31/Modelica/Math/package.mo:439:9-439:49:writable Error: Wrong type or wrong number of arguments to abs(A[:,i])'.
Users/martin/dev/trunk/build//lib/omlibrary/msl31/Modelica/Math/package.mo:439:9-439:49:writable Error: No matching function found for abs in component <NO COMPONENT>
candidates are function(x:Integer) => Integer
Users/martin/dev/trunk/build//lib/omlibrary/msl31/Modelica/Math/package.mo:439:9-439:49:writable Error: Wrong type or wrong number of arguments to abs(A[:,i])'.
Users/martin/dev/trunk/build//lib/omlibrary/msl31/Modelica/Math/package.mo:439:9-439:49:writable Error: Wrong type or wrong number of arguments to sum(abs(A[:,i]))'.
Users/martin/dev/trunk/build//lib/omlibrary/msl31/Modelica/Math/package.mo:439:9-439:49:writable Error: Wrong type or wrong number of arguments to max(result, sum(abs(A[:,i])))'.
# Error encountered! Exiting...
# Please check the error message and the flags.
Execution failed!}}}