aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator.mo
blob: 632fbc776c7f9259e5d5e8d7064c7fb858961c20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
block PolynomialEvaluator
 parameter Real a[:];
 input Real x;
 output Real y;
protected
 constant Real 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;