Notice that the basis that Macaulay2 uses for Hom(A^3,A^2) is different than the basis used by Singular.
The function contraHom of the Singular book in example 2.1.7 could be coded in the following way.
i5 : contraHom = (M, s) -> (
(n,m) := (numgens target M, numgens source M);
R := mutableMatrix(ring M, s*n, s*m);
for b from 0 to m-1 do
for a from 0 to s-1 do
for c from 0 to n-1 do
R_(a*n+c,a*m+b) = M_(b,c);
matrix R
)
o5 = contraHom
o5 : FunctionClosure