Opened 8 years ago
Closed 8 years ago
#4974 closed defect (fixed)
ComplexMath.'abs' is not inlined
| Reported by: | Francesco Casella | Owned by: | somebody |
|---|---|---|---|
| Priority: | critical | Milestone: | 1.13.0 |
| Component: | Backend | Version: | |
| Keywords: | Cc: | Martin Sjölund, Willi Braun, Vitalij Ruge |
Description
Please run this simple model with -d=dumpdaelow
model TestComplexAbs Complex z; Real x; equation z = Complex(time, 1); x = Modelica.ComplexMath.'abs'(z); end TestComplexAbs;
The output is
1/1 (1): z.re = time [dynamic |0|0|0|0|] 2/2 (1): z.im = 1.0 [dynamic |0|0|0|0|] 3/3 (1): x = Modelica.ComplexMath.'abs'(z) [dynamic |0|0|0|0|]
For some reason, the 'abs' function is not inlined as required by the annotation in its definition, otherwise the third line should read
x = (z.re^2 + z.im^2)^0.5
Please make sure inlining works with this function, otherwise the backend cannot generate symbolic Jacobians if the function is involved in a nonlinear algebraic loop
Change History (6)
comment:1 by , 8 years ago
| Cc: | added |
|---|
comment:2 by , 8 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:3 by , 8 years ago
@vitalij, there was some issue with the NF that did not pass the Inline annotation to the backend. This should now be fixed, I'll check again tomorrow.
comment:4 by , 8 years ago
Unfortunately, if I run the model with -d=newInst,dumpdaelow I still get
Equations (3, 3) ======================================== 1/1 (1): z.im = 1.0 [dynamic |0|0|0|0|] 2/2 (1): z.re = time [dynamic |0|0|0|0|] 3/3 (1): x = Modelica.ComplexMath.'abs'(z) [dynamic |0|0|0|0|]
@vitalij, how did you get the result reported in comment:2?
comment:5 by , 8 years ago
setCommandLineOptions("+d=optdaedump,newInst");
loadModel(Modelica);
getErrorString();
loadString("
model TestComplexAbs
Complex z;
Real x;
equation
z = Complex(time, 1);
x = Modelica.ComplexMath.'abs'(z);
end TestComplexAbs;
");
getErrorString();
simulate(TestComplexAbs);
comment:6 by , 8 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Oops, sorry, I missed the right -d flag.
Thanks @vitalij!

@casella
Inlining of functions will be done with
normalInlineFunctionI guess we do partitional some inlining for records like constructor in frondend and inlining function in backend in the optdaemodul
normalInlineFunction.