<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns3="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="sum" xml:lang="pt">
    <refnamediv>
        <refname>sum</refname>
        <refpurpose>soma (soma linha, soma coluna) de entradas de um vetor ou
            matriz
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Seqüência de Chamamento</title>
        <synopsis>y=sum(x)
            y=sum(x,'r') ou y=sum(x,1)

            y=sum(x,'c') ou y=sum(x,2)

            y=sum(x,'m')
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Parâmetros</title>
        <variablelist>
            <varlistentry>
                <term>x</term>
                <listitem>
                    <para>vetor ou matriz (de reais, complexos, esparso(a) ou de
                        polinômios)
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>y</term>
                <listitem>
                    <para>escalar ou vetor </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Descrição</title>
        <para>
            Para um vetor ou matriz <literal>x</literal>,
            <literal>y=sum(x)</literal> retorna no escalar <literal>y</literal> a soma
            de todas as entradas de <literal>x</literal>.
        </para>
        <para>
            <literal>y=sum(x,'r')</literal> (ou, equivalentemente,
            <literal>y=sum(x,1)</literal>) é a soma linha a linha:: <literal>y(j)=
                sum(x(:,j))
            </literal>
            .<literal>y</literal> é um vetor linha.
        </para>
        <para>
            <literal>y=sum(x,'c')</literal> (ou, equivalentemente,
            <literal>y=sum(x,2)</literal>) é a soma coluna a coluna. Retorna em cada
            entrada do vetor coluna <literal>y</literal> a soma : <literal>y(i)=
                sum(x(i,:))
            </literal>
            )).
        </para>
        <para>
            <literal>y=sum(x,'m')</literal> é a soma ao longo da primeira
            dimensão "não-singleton" de <literal>x</literal> (para compatibilidade com
            Matlab).
        </para>
    </refsection>
    <refsection>
        <title>Exemplos</title>
        <programlisting role="example"><![CDATA[
A=[1,2;3,4];
trace(A)-sum(diag(A))
sum(A,'c')-A*ones(2,1)
sum(A+%i)
A=sparse(A);sum(A,'c')-A*ones(2,1)
s=poly(0,'s');
M=[s,%i+s;s^2,1];
sum(M),sum(M,2)
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>Ver Também</title>
        <simplelist type="inline">
            <member>
                <link linkend="cumsum">cumsum</link>
            </member>
            <member>
                <link linkend="prod">prod</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
