Description
In Macaulay2, each free module over a polynomial ring comes equipped with a
monomial order and this routine returns the matrix whose
ith column is the lead term of the
i th column of
f.
i1 : R = QQ[a..d];

i2 : f = matrix{{0,a^2b*c},{c,d}}
o2 =  0 a2bc 
 c d 
2 2
o2 : Matrix R < R

i3 : leadTerm f
o3 =  0 a2 
 c 0 
2 2
o3 : Matrix R < R

Coefficients are included in the result:
i4 : R = ZZ[a..d][x,y,z];

i5 : f = matrix{{0,(a+b)*x^2},{c*x, (b+c)*y}}
o5 =  0 (a+b)x2 
 cx (b+c)y 
2 2
o5 : Matrix R < R

i6 : leadTerm f
o6 =  0 ax2 
 cx 0 
2 2
o6 : Matrix R < R

The argument
f can also be
a Gröbner basis, in which case the lead term matrix of the generating matrix of
f is returned.