# Singular

#### D.15.20.9 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); ==> Graded homomorphism: r^3 + r(-1) <- r(-1)^2, given by a matrix, with degr\ ees: ==> ..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); ==> Graded homomorphism: r(-15) + r(-1)^2 <- r(-2), given by a matrix, with d\ egrees: ==> ..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); ==> Graded homomorphism: r^3 + r(-1) + r(-15) + r(-1)^2 <- r(-1)^2 + r(-2), g\ iven by a matrix, with degrees: ==> ..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, ==> x, x+y,0, 0, 0,0, ==> 0, y, 0, 0, 0,0, ==> 0, 0, 0, 0, 0,0, ==> 0, 0, x+y,0, 0,0, ==> 0, 0, x, x+y,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, x,0, ==> 0, 0, 0, 0, y,0, ==> 0, 0, 0, 0, 0,0, ==> 0, 0, 0, 0, 0,x, ==> 0, 0, 0, 0, 0,y homog(D); ==> 1 grview(D); ==> Graded homomorphism: ==> r^3 + r(-1) + r^3 + r(-1) + r(1) + r(2) + r(-15) + r(-1)^2 + r(-15) + r(-\ 1)^2 <- ==> r(-1)^4 + r(-2)^2, given by a matrix, with degrees: ==> ..1 ..2 ..3 ..4 ..5 ..6 .... ==> --- --- --- --- --- --- +... ==> 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 2 2 module F = grobj( module([x,y,0]), intvec(1,1,5) ); grview(F); ==> Graded homomorphism: r(-1)^2 + r(-5) <- r(-2), given by a matrix, with de\ grees: ==> ..1 .... ==> --- +... ==> 1 : 1 |..1 ==> 1 : 1 |..2 ==> 5 : - |..3 ==> === ==> 2 module T = grsum( F, grsum( grtwist(1, 10), B ) ); grview(T); ==> Graded homomorphism: r(-1)^2 + r(-5) + r(10) + r(-15) + r(-1)^2 <- r(-2)^\ 2 ==> , given by a matrix, with degrees: ==> ...1 ...2 ..... ==> ---- ---- +.... ==> 1 : 1 - |...1 ==> 1 : 1 - |...2 ==> 5 : - - |...3 ==> -10 : - - |...4 ==> 15 : - - |...5 ==> 1 : - 1 |...6 ==> 1 : - 1 |...7 ==> ==== ==== ==> 2 2 // if( defined(assumeLevel0) ){ assumeLevel = assumeLevel0; } else { kill assumeLevel; } // restore the state of aL ```