# Singular

#### D.15.10.8 grsum

Procedure from library `gradedModules.lib` (see gradedModules_lib).

Usage:
grsum(A, B), graded objects A and B

Return:
graded direct sum of input objects

Purpose:
compute the graded direct sum of A and B

Example:
 ```LIB "gradedModules.lib"; // if( defined(assumeLevel) ){ int assumeLevel0 = assumeLevel; } else { int assumeLevel; export(assumeLevel); }; assumeLevel = 5; ring r=32003,(x,y,z),dp; module A = grobj( module([x+y, x, 0, 0], [0, x+y, y, 0]), intvec(0,0,0,1) ); grview(A); ==> 1 2 ==> -------- ==> 0 : 1 . | 1 ==> 0 : 1 1 | 2 ==> 0 : . 1 | 3 ==> 1 : . . | 4 ==> ======== ==> 1 1 module B = grobj( module([0,x,y]), intvec(15,1,1) ); grview(B); ==> 1 ==> ---- ==> 15 : . | 1 ==> 1 : 1 | 2 ==> 1 : 1 | 3 ==> ==== ==> 2 module C = grsum(A,B); print(C); ==> x+y,0, 0, ==> x, x+y,0, ==> 0, y, 0, ==> 0, 0, 0, ==> 0, 0, 0, ==> 0, 0, x, ==> 0, 0, y homog(C); ==> 1 grview(C); ==> 1 2 3 ==> ------------ ==> 0 : 1 . . | 1 ==> 0 : 1 1 . | 2 ==> 0 : . 1 . | 3 ==> 1 : . . . | 4 ==> 15 : . . . | 5 ==> 1 : . . 1 | 6 ==> 1 : . . 1 | 7 ==> ============ ==> 1 1 2 module D = grsum( grsum(grpower(A,2), grtwist(1,1)), grsum(grtwist(1,2), grpower(B,2)) ); print(D); ==> x+y,0, 0, 0, 0,0,0,0, ==> x, x+y,0, 0, 0,0,0,0, ==> 0, y, 0, 0, 0,0,0,0, ==> 0, 0, 0, 0, 0,0,0,0, ==> 0, 0, x+y,0, 0,0,0,0, ==> 0, 0, x, x+y,0,0,0,0, ==> 0, 0, 0, y, 0,0,0,0, ==> 0, 0, 0, 0, 0,0,0,0, ==> 0, 0, 0, 0, 0,0,0,0, ==> 0, 0, 0, 0, 0,0,0,0, ==> 0, 0, 0, 0, 0,0,0,0, ==> 0, 0, 0, 0, 0,0,x,0, ==> 0, 0, 0, 0, 0,0,y,0, ==> 0, 0, 0, 0, 0,0,0,0, ==> 0, 0, 0, 0, 0,0,0,x, ==> 0, 0, 0, 0, 0,0,0,y homog(D); ==> 1 grview(D); ==> 1 2 3 4 5 6 7 8 ==> -------------------------------- ==> 0 : 1 . . . . . . . | 1 ==> 0 : 1 1 . . . . . . | 2 ==> 0 : . 1 . . . . . . | 3 ==> 1 : . . . . . . . . | 4 ==> 0 : . . 1 . . . . . | 5 ==> 0 : . . 1 1 . . . . | 6 ==> 0 : . . . 1 . . . . | 7 ==> 1 : . . . . . . . . | 8 ==> -1 : . . . . . . . . | 9 ==> -2 : . . . . . . . . | 10 ==> 15 : . . . . . . . . | 11 ==> 1 : . . . . . . 1 . | 12 ==> 1 : . . . . . . 1 . | 13 ==> 15 : . . . . . . . . | 14 ==> 1 : . . . . . . . 1 | 15 ==> 1 : . . . . . . . 1 | 16 ==> ================================ ==> 1 1 1 1 -1 -2 2 2 module F = grobj( module([x,y,0]), intvec(1,1,5) ); grview(F); ==> 1 ==> ---- ==> 1 : 1 | 1 ==> 1 : 1 | 2 ==> 5 : . | 3 ==> ==== ==> 2 module T = grsum( F, grsum( grtwist(1, 10), B ) ); grview(T); ==> 1 2 3 ==> --------------- ==> 1 : 1 . . | 1 ==> 1 : 1 . . | 2 ==> 5 : . . . | 3 ==> -10 : . . . | 4 ==> 15 : . . . | 5 ==> 1 : . . 1 | 6 ==> 1 : . . 1 | 7 ==> =============== ==> 2 -10 2 // if( defined(assumeLevel0) ){ assumeLevel = assumeLevel0; } else { kill assumeLevel; } // restore the state of aL ```