aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/examples/modelica_models/polynomial_evaluator.mo
blob: f11d375f73b9ec63f07652a5bb11681a77443f9b (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 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;