File: sum.cat

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (41 lines) | stat: -rw-r--r-- 1,092 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

sum(1)                         Scilab Function                         sum(1)
NAME
  sum - sum (row sum, column sum) of vector/matrix entries

CALLING SEQUENCE
  y=sum(x)
  y=sum(x,'r') or y=sum(x,1)

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

PARAMETERS

  x         : vector or matrix (real, complex, sparse or polynomial)

  y         : scalar or vector

DESCRIPTION
  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. It returns
  in each entry of the row vector y the sum of the rows of x (The sum is per-
  formed on the row indice : y(j)= sum(x(i,j),i=1,m)).

  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 of the columns of x
  (The sum is performed on the column indice:  y(i)= sum(x(i,j),j=1,n))).

EXAMPLE
  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)

SEE ALSO
  cumsum, prod