If M is finite dimensional over k, the degree of M is its dimension over k. Otherwise, the degree of M is the multiplicity of M, i.e., the integer d such that the Hilbert polynomial of M has the form z > d z^e/e! + lower terms in z.



The algorithm computes the poincare polynomial of M, divides it by 1T as often as possible, then evaluates it at T=1. When the module has finite length, the result is the Hilbert series evaluated at 1, that is the dimension over the ground field, which for a graded (homogeneous) is the same as the length.