If g is omitted, then the identity map on the target of r is used as g, and the cokernel of r is returned. If r is omitted (but not the comma), then a zero map to the target of g is used as r, and the image of g is returned.
The general form in which modules are represented in Macaulay 2 is as subquotients, and subquotient modules are often returned as values of computations, as in the example below.
i1 : R = ZZ/101[a..d] o1 = R o1 : PolynomialRing |
i2 : M = kernel vars R ++ cokernel vars R o2 = subquotient ({1} | 0 0 0 -b -c -d 0 |, {1} | 0 0 0 0 |) {1} | 0 -c -d a 0 0 0 | {1} | 0 0 0 0 | {1} | -d b 0 0 a 0 0 | {1} | 0 0 0 0 | {1} | c 0 b 0 0 a 0 | {1} | 0 0 0 0 | {0} | 0 0 0 0 0 0 1 | {0} | a b c d | 5 o2 : R-module, subquotient of R |
i3 : generators M o3 = {1} | 0 0 0 -b -c -d 0 | {1} | 0 -c -d a 0 0 0 | {1} | -d b 0 0 a 0 0 | {1} | c 0 b 0 0 a 0 | {0} | 0 0 0 0 0 0 1 | 5 7 o3 : Matrix R <--- R |
i4 : relations M o4 = {1} | 0 0 0 0 | {1} | 0 0 0 0 | {1} | 0 0 0 0 | {1} | 0 0 0 0 | {0} | a b c d | 5 4 o4 : Matrix R <--- R |
i5 : M === subquotient(generators M, relations M) o5 = true |
i6 : prune M o6 = cokernel {2} | 0 0 0 0 b a 0 0 | {2} | 0 0 0 0 d 0 a 0 | {2} | 0 0 0 0 -c 0 0 a | {2} | 0 0 0 0 0 0 c d | {2} | 0 0 0 0 0 d -b 0 | {2} | 0 0 0 0 0 -c 0 -b | {0} | d c b a 0 0 0 0 | 7 o6 : R-module, quotient of R |