# sum(Complex) -- make the direct sum of all terms

## Synopsis

• Function: sum
• Usage:
sum C
sum f
• Inputs:
• C, , or f,
• Outputs:
• , or , if the input is a complex map

## Description

This is the forgetful functor from the category of chain complexes to the category of modules. A chain complex $C$ is sent to the direct sum $\bigoplus_i C_i$ of its terms. A map of chain complexes $f \colon C \to D$ is sent to the direct sum $\bigoplus_i f_i \colon \bigoplus_i C_i \to \bigoplus_i D_i$.

 i1 : S = ZZ/101[a,b,c]; i2 : C = koszulComplex {a,b,c} 1 3 3 1 o2 = S <-- S <-- S <-- S 0 1 2 3 o2 : Complex i3 : sum C 8 o3 = S o3 : S-module, free, degrees {0..1, 2:1, 3:2, 3} i4 : assert(rank sum C == 2^3)
 i5 : f = randomComplexMap(C, C, InternalDegree => 1, Cycle => true) 1 1 o5 = 0 : S <------------------- S : 0 | -5a-27b-40c | 3 3 1 : S <---------------------------------------------- S : 1 {1} | -5a-46b+42c -7b+24c 29b+9c | {1} | 19a-8c 2a-27b-14c -29a-30c | {1} | 19a+8b -24a-26b -14a+3b-40c | 3 3 2 : S <---------------------------------------------- S : 2 {2} | 2a-46b-30c -29a-10c -29b+22c | {2} | -24a-29b -14a-36b+42c -38b+24c | {2} | -16a-8b 39a-8c 24a+3b-14c | 1 1 3 : S <----------------------- S : 3 {3} | 24a-36b-30c | o5 : ComplexMap i6 : g = sum f o6 = {0} | -5a-27b-40c 0 0 0 0 {1} | 0 -5a-46b+42c -7b+24c 29b+9c 0 {1} | 0 19a-8c 2a-27b-14c -29a-30c 0 {1} | 0 19a+8b -24a-26b -14a+3b-40c 0 {2} | 0 0 0 0 2a-46b-30c {2} | 0 0 0 0 -24a-29b {2} | 0 0 0 0 -16a-8b {3} | 0 0 0 0 0 ------------------------------------------------------------------------ 0 0 0 | 0 0 0 | 0 0 0 | 0 0 0 | -29a-10c -29b+22c 0 | -14a-36b+42c -38b+24c 0 | 39a-8c 24a+3b-14c 0 | 0 0 24a-36b-30c | 8 8 o6 : Matrix S <--- S i7 : assert(g^2 === sum f^2) i8 : assert(target g === sum target f) i9 : assert(source g === sum source f) i10 : h = sum dd^C o10 = {0} | 0 a b c 0 0 0 0 | {1} | 0 0 0 0 -b -c 0 0 | {1} | 0 0 0 0 a 0 -c 0 | {1} | 0 0 0 0 0 a b 0 | {2} | 0 0 0 0 0 0 0 c | {2} | 0 0 0 0 0 0 0 -b | {2} | 0 0 0 0 0 0 0 a | {3} | 0 0 0 0 0 0 0 0 | 8 8 o10 : Matrix S <--- S i11 : assert(h^2 == 0)