Julio, I think Base.Cartesian will be helpful for this (in particular, @nloops and @nexprs):
http://julia.readthedocs.org/en/latest/devdocs/cartesian/ One issue that will come up is if you do something like "@nexprs 2 j->(i_j = 1)", the "2" in there can't be a variable. You can work around this though by doing something like q = :( @nexprs replacethissymbol j->(i_j = 1) ) N = 10 replacesymbol!(q, :replacethissymbol, N) eval(q) where "replacesymbol!" is a function that traverses the expression "q" and replaces each instance of the symbol ":replacethissymbol" with the value of the variable "N". I hope that helps! On Tuesday, May 19, 2015 at 11:24:04 AM UTC-6, Júlio Hoffimann wrote: > > Hi, > > Given an integer N >= 0 and a m-by-n matrix X. Denote Xj the j-th column > of X. > > How would you form the following matrix expression in Julia? > > result[:,j] = > [ > 1 # order 0 term > > Xj[1] # order 1 terms > Xj[2] > Xj[3] > . > . > . > Xj[m] > > Xj[1]^2 # order 2 terms > Xj[2]^2 > . > . > . > Xj[m]^2 > Xj[1]*Xj[2] > Xj[1]*Xj[3] > Xj[2]*Xj[3] > . > . > . > Xj[m-1]*Xj[m] > . > . > . > Xj[1]*...*Xj[m] # order N terms > ] > > I'm trying to get something similar to the Vandermonde matrix ( > http://en.wikipedia.org/wiki/Vandermonde_matrix), but with additional > mixed terms. I know Julia has some nice features for expression generation, > can someone guide me through it? > > Regards, > Júlio. >
