Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding test for parameter record bindings
Belonging to [master]: - OpenModelica/OMCompiler#1773 - OpenModelica/OpenModelica-testsuite#678
- Loading branch information
1 parent
8f278a2
commit 505f10d
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function 'sum' "Return sum of complex vector" | ||
input Complex v[:] "Vector"; | ||
output Complex result "Complex sum of vector elements"; | ||
algorithm | ||
result:=Complex(sum(v[i].re for i in 1:size(v,1)), sum(v[i].im for i in 1:size(v,1))); | ||
annotation(Inline=true); | ||
end 'sum'; | ||
|
||
model TestComplexSum1 | ||
parameter Complex a[2]={Complex(1,2),Complex(2,3)}; | ||
parameter Complex sum1 = 'sum'(a); | ||
parameter Complex sum2 = Complex(sum(a.re),sum(a.im)); | ||
end TestComplexSum1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// status: correct | ||
|
||
loadFile("TestComplexSum.mo");getErrorString(); | ||
loadModel(Complex,{"3.2.2"});getErrorString(); | ||
simulate(TestComplexSum1,simflags="-output sum1.re,sum1.im,sum2.re,sum2.im");getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "TestComplexSum1_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'TestComplexSum1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-output sum1.re,sum1.im,sum2.re,sum2.im'", | ||
// messages = "stdout | info | The initialization finished successfully without homotopy method. | ||
// time=1,sum1.re=3,sum1.im=5,sum2.re=3,sum2.im=5 | ||
// stdout | info | The simulation finished successfully. | ||
// " | ||
// end SimulationResult; | ||
// "[simulation/modelica/records/TestComplexSum.mo:11:3-11:36:writable] Notification: Moving binding to equation section and setting fixed attribute of sum1.re to false. This is done to work around a compiler design flaw (there is no good way to represent bindings that span multiple variables). | ||
// [simulation/modelica/records/TestComplexSum.mo:11:3-11:36:writable] Notification: Moving binding to equation section and setting fixed attribute of sum1.im to false. This is done to work around a compiler design flaw (there is no good way to represent bindings that span multiple variables). | ||
// " | ||
// endResult |