Here's how I'd approach the problem, in pseudo-code:

R = [] # This could be typed and pre-allocated with the proper length
for i=1:N
    factors = combinations_with_replacement(Xj, i)
    for f in factors
        push!(R, prod(f))
    end
end


The only trouble is that combinations_with_replacement function.  I don't 
see a Julia version anywhere at the moment.  See Python's itertools 
package: 
https://docs.python.org/2/library/itertools.html#itertools.combinations_with_replacement

On Wednesday, May 20, 2015 at 2:22:59 PM UTC-4, Júlio Hoffimann wrote:
>
> David, thank you very much for the detailed explanation, will read through 
> it.
>
> Steven, sorry for not explaining the problem clearly. My issue is 
> basically trying to figure out a way to loop over all possible combinations 
> of exponents (e1, e2, e3) for which the sum is less or equal to N and 
> generate a vector with the terms Xj[1]^e1*Xj[2]^e2*Xj[3]^e3.
>
> The j-th column of the resulting matrix contains the terms of this 
> polynomial evaluated at the j-th column of X.
>
> -Júlio
>

Reply via email to