| #### D.2.3.16 sum Procedure from library `general.lib` (see general_lib). Usage: sum(id[,v]); id ideal/vector/module/matrix/intvec/intmat/list, v intvec (default: v=1..number of entries of id) Assume: list members can be added. Return: The sum of all entries of id [with index given by v] of type depending on the entries of id. Note: If id is not a list, id is treated as a list of polys resp. integers. A module m is identified with the corresponding matrix M (columns of M generate m). If v is outside the range of id, we have the empty sum and the result will be 0 (of type int). Example:
    LIB "general.lib";
    ring r1 = 0,(x,y,z),dp;
    vector pv = [xy,xz,yz,x2,y2,z2];
    sum(pv);
    ==> x2+xy+y2+xz+yz+z2
    sum(pv,2..5);
    ==> x2+y2+xz+yz
    matrix M[2][3] = 1,x,2,y,3,z;
    intvec w=2,4,6;
    sum(M,w);
    ==> x+y+z
    intvec iv = 1,2,3,4,5,6,7,8,9;
    sum(iv,2..4);
    ==> 9
    iv = intvec(1..100);
    sum(iv);
    ==> 5050
    ring r2 = 0,(x(1..10)),dp;
    sum(x(3..7),intvec(1,3,5));
    ==> x(3)+x(5)+x(7)

User manual for Singular version 4.4.0, 2024, generated by texi2html.