I'm trying to write a function on Macaulay2 such that, given a square polynomial matrix in input, put out a list $\{(1,p_1(x)), \ldots , (r,p_r(x))\}$ where $r$is the rank of the matrix and $p_i(x)$ is the gcd of all the minors $i\times i$.
I tried the following code:
function=(M)->(
r=rank(M);
d1=gens saturate minors(r,M);
for i from r-1 to 1 list (
d2=gens saturate minors(i,M);
if d1//d2!=1 then (i+1,d1//d2), d1=d2;
if i==1 then (i+1,d1)
else continue
))
I try to compile and there is no error declared, but it does not put out any list. How can I fix this?
I'm not an expert on Macaulay2, but from the documentation it looks like you can't loop "downward" from $r-1$ down to $1$. You would have to start the loop at $i=1$.