aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/examples/modelica_models/polynomial_evaluator.mo
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-12-17 19:33:11 -0800
committerbnewbold <bnewbold@robocracy.org>2016-12-17 19:33:11 -0800
commit2e634496a6f362017d8f5f643d4ad30a3507dff9 (patch)
treef6500ad5f05082a062794f90e2afd1998bb33ec1 /modelica-parser-lalrpop/examples/modelica_models/polynomial_evaluator.mo
parent9f82aceb9fbdb42f332d68f4a423123bd0788b2c (diff)
downloadmodelthing-2e634496a6f362017d8f5f643d4ad30a3507dff9.tar.gz
modelthing-2e634496a6f362017d8f5f643d4ad30a3507dff9.zip
update/expand parser examples
Diffstat (limited to 'modelica-parser-lalrpop/examples/modelica_models/polynomial_evaluator.mo')
-rw-r--r--modelica-parser-lalrpop/examples/modelica_models/polynomial_evaluator.mo14
1 files changed, 14 insertions, 0 deletions
diff --git a/modelica-parser-lalrpop/examples/modelica_models/polynomial_evaluator.mo b/modelica-parser-lalrpop/examples/modelica_models/polynomial_evaluator.mo
new file mode 100644
index 0000000..f11d375
--- /dev/null
+++ b/modelica-parser-lalrpop/examples/modelica_models/polynomial_evaluator.mo
@@ -0,0 +1,14 @@
+block PolynomialEvaluator
+ parameter Real a[:];
+ input Real x;
+ output Real y;
+protected
+ constant n = size(a, 1)-1;
+ Real xpowers[n+1];
+equation
+ xpowers[1] = 1;
+ for i in 1:n loop
+ xpowers[i+1] = xpowers[i]*x;
+ end for;
+ y = transpose(a) * xpowers;
+end PolynomialEvaluator;