aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator.mo
diff options
context:
space:
mode:
Diffstat (limited to 'modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator.mo')
-rw-r--r--modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator.mo14
1 files changed, 14 insertions, 0 deletions
diff --git a/modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator.mo b/modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator.mo
new file mode 100644
index 0000000..f11d375
--- /dev/null
+++ b/modelica-parser-lalrpop/examples/modelica_other/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;