MultiSum

block MultiSum "Sum of Reals: y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]"
    extends Modelica.Blocks.Interfaces.PartialRealMISO;

    parameter Real k[nu] = fill(1, nu) "Input gains";
equation
    if 0 < size(u, 1) then 
        y = k * u;
    else 
        y = 0;
    end if;

    annotation (
        Icon(graphics = {
            Text(
                extent = {
                    {-200, -110}, 
                    {200, -140}},
                textString = "%k"), 
            Text(
                extent = {
                    {-72, 68}, 
                    {92, -68}},
                textString = "+")}),
        Documentation(info = "<html>\n<p>\nThis blocks computes the scalar Real output \"y\" as sum of the elements of the\nReal input signal vector u:\n</p>\n<blockquote><pre>\ny = k[1]*u[1] + k[2]*u[2] + ... k[N]*u[N];\n</pre></blockquote>\n\n<p>\nThe input connector is a vector of Real input signals.\nWhen a connection line is drawn, the dimension of the input\nvector is enlarged by one and the connection is automatically\nconnected to this new free index (thanks to the\nconnectorSizing annotation).\n</p>\n\n<p>\nThe usage is demonstrated, e.g., in example\n<a href=\"modelica://Modelica.Blocks.Examples.RealNetwork1\">Modelica.Blocks.Examples.RealNetwork1</a>.\n</p>\n\n<p>\nIf no connection to the input connector \"u\" is present,\nthe output is set to zero: y=0.\n</p>\n\n</html>"));
end MultiSum;