Question: How to efficiently implement the addition of a monomial to a list of monomials?

Hello

I could not come up with a better title, so I apologize for that.  Let me explain what I am trying to implement using an example. 

Consider the following list of monomials (a 3D model,  4 monomials altogether):

model := [x^2*y*alpha[1, 11], x*z^2*alpha[2, 15], y^2*z*alpha[3, 17] + y*z*alpha[3, 8]]

The idea is to generate the set of all models by adding a non-repetitive monomial from the following list to model.

[alpha[i, 0], alpha[i, 1]*x, alpha[i, 2]*y, alpha[i, 3]*z, alpha[i, 4]*x^2, alpha[i, 5]*y*x, alpha[i, 6]*z*x, alpha[i, 7]*y^2, alpha[i, 8]*z*y, alpha[i, 9]*z^2, alpha[i, 10]*x^3, alpha[i, 11]*y*x^2, alpha[i, 12]*z*x^2, alpha[i, 13]*y^2*x, alpha[i, 14]*z*y*x, alpha[i, 15]*z^2*x, alpha[i, 16]*y^3, alpha[i, 17]*z*y^2, alpha[i, 18]*z^2*y, alpha[i, 19]*z^3]

where i indicates the coordinate where the monomial will be included.  Example: if alpha[i, 2]*y is to be added to the second coordinate of model it goes as alpha[2,2]*y. Note that alpha[i, 15]*z^2*x cannot be added to coordinate 2 since it is already there.  

The result will be a list of 56 models with 5 monomials. 

How can I do that efficiently?  

Many thanks

Ed.

PS. I have implemented something similar to the problem above, but I have used too many 'for' loops. 

Please Wait...