The modules should be defined over the same ring.
In the following example we check that the map does implement composition.
i1 : R = QQ[x,y]
o1 = R
o1 : PolynomialRing
|
i2 : M = image vars R ++ R^2
o2 = image | x y 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |
3
o2 : R-module, submodule of R
|
i3 : f = compose(M,M,M);
o3 : Matrix
|
i4 : H = Hom(M,M);
|
i5 : g = H_{0}
o5 = {0} | 1 |
{0} | 0 |
{0} | 0 |
{0} | 0 |
{0} | 0 |
{0} | 0 |
{0} | 0 |
{1} | 0 |
{1} | 0 |
{1} | 0 |
{1} | 0 |
o5 : Matrix
|
i6 : h = homomorphism g
o6 = {1} | 1 0 0 0 |
{1} | 0 1 0 0 |
{0} | 0 0 0 0 |
{0} | 0 0 0 0 |
o6 : Matrix
|
i7 : f * (g ** g)
o7 = {0} | 1 |
{0} | 0 |
{0} | 0 |
{0} | 0 |
{0} | 0 |
{0} | 0 |
{0} | 0 |
{1} | 0 |
{1} | 0 |
{1} | 0 |
{1} | 0 |
o7 : Matrix
|
i8 : h' = homomorphism oo
o8 = {1} | 1 0 0 0 |
{1} | 0 1 0 0 |
{0} | 0 0 0 0 |
{0} | 0 0 0 0 |
o8 : Matrix
|
i9 : h' === h * h
o9 = true
|
i10 : assert oo
|