

# Michael Monagan
# bottom up minor expansion
detbot := proc(A,n) local i,R,S,c,j,T,d,numterms,multiply,N,k,t;
    for i to n do T[[i]] := A[i,n] od;
    S := [seq([i],i=1..n)];
    for i from 2 to n do
        if i>6 then printf("%sstarting column %d  \n",cat(" "$n-i),n-i+1) fi;
        R := combinat[choose](n,i);
        for c in R do
            d := 0;
            for j to nops(c) do
                t := (-1)^(j-1)*A[c[j],n-i+1];
                if t=0 then next fi;
                d := d + expand(t*T[subsop(j=NULL,c)]);
            od;
            T[c] := d;
        od;
        if i>3 then printf("%sdone column %d  \n",cat(" "$n-i),n-i+1) fi;
        for c in S do T[c] := evaln(T[c]) od;
        S := R;
    od;
    d := T[[seq(i,i=1..n)]];
end:


#A := Matrix([[1,u,u^2],[1,v,v^2],[1,w,w^2]]);
#factor(detbot(A,3));
#T4 := Matrix([[u,v,w,x],[v,u,v,w],[w,v,u,v],[x,w,v,u]]);
#factor(detbot(T4,4));



