Question: more efficient way to compute coefficients than "coeff"?

Hi, all, After some computation, I got a huge polynomial: a00*x^123+a45*x^233+a02*x^123+a67*x^156+a47*x^67+.......(with more than 30,000 monomials). This generated polynomial has some features: 1: the degree of each monomial is not more than 256. 2:each monomial only has ONE coefficient. 3:There are two or more monomials have the same degree, so they can be combined together. Such as a00*x^123+a02*x^123=(a00+a02)*x^123. 4:for any coefficient a[ij], i is from 0 though 15, j is also from 0 through 15. What I want to do is to obtain the coefficients of same degree. The degree is from 0 through 255. Let us take a small example: a00*x^2+a02*x^3+a00*x^3+a12*x^1+a01*x^2+a11 which is actually equal to (a00+a01)*x^2+(a02+a00)*x^3+a12*x^1+a11*x^0 My objective is to get the matrix of following : a00 a01 a02 a10 a11 a12 0 0 0 0 1 0---------->a11*x^0 0 0 0 0 0 1---------->a12*x^1 1 1 0 0 0 0---------->(a00+a01)*x^2 1 0 1 0 0 0---------->(a02+a00)*x^3 What I did right now is to TL := []; L := [] for i from 0 to 255 do for j from 0 to 15 do for k from 0 to 15 do TL := [op(TL), coeff( coeff(reduce, x,i), a[j, k], 1)]; end do end do L := [op(L), TL]; TL := [] end do TL will store all the coefficients of the same degree. L stores all the coefficients of all degrees. But this method is pretty slow. Would you guys like to suggest a better way to do it?
Please Wait...