# Sum

block Sum "Output the sum of the elements of the input vector"
extends Interfaces.ComplexMISO;

parameter Complex k[nin] = fill(Complex(1, 0), nin) "Optional: sum coefficients";
equation
y = k * uInternal;

annotation (
defaultComponentName = "sum1",
Documentation(info = "<html>\n<p>\nThis blocks computes output <code>y</code> as\n<em>sum</em> of the elements of the input signal vector\n<code>u</code>:\n</p>\n<pre>\n    <code>y</code> = <code>u</code>[1] + <code>u</code>[2] + ...;\n</pre>\n<p>\nExample:\n</p>\n<pre>\n     parameter:   nin = 3;\n\n  results in the following equations:\n\n     y = u[1] + u[2] + u[3];\n</pre>\n\n</html>"),
Icon(
coordinateSystem(
preserveAspectRatio = true,
extent = {
{-100, -100},
{100, 100}}),
graphics = {
Line(points = {
{26, 42},
{-34, 42},
{6, 2},
{-34, -38},
{26, -38}})}),
Diagram(
coordinateSystem(
preserveAspectRatio = true,
extent = {
{-100, -100},
{100, 100}}),
graphics = {
Rectangle(
extent = {
{-100, -100},
{100, 100}},
lineColor = {0, 0, 255},
fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid),
Line(points = {
{26, 42},
{-34, 42},
{6, 2},
{-34, -38},
{26, -38}})}));
end Sum;