Scilab Reference Manual |
---|
sum — sum (row sum, column sum) of vector/matrix entries
y=sum(x) y=sum(x,'r') or y=sum(x,1) y=sum(x,'c') or y=sum(x,2)
For a vector or a matrix x, y=sum(x) returns in the scalar y the sum of all the entries of x.
y=sum(x,'r') (or, equivalently, y=sum(x,1)) is the rowwise sum: y(j)= sum(x(:,j)). y is a row vector
y=sum(x,'c') (or, equivalently, y=sum(x,2)) is the columnwise sum. It returns in each entry of the column vector y the sum : y(i)= sum(x(i,:)))).
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)
<< subf | sysconv >> |