On Fri, Feb 5, 2010 at 1:05 PM, Jinglei Hu
<jingleihu@xxxxxxxxx> wrote:
Thanks. Could you show how to do with preprocessor?
Aron suggested you to write your *own* preprocessor, not using the standard C/C++ preprocessor which cannot help here! So a lot of work, and your code will require an extra tools to be compiled, and all of that just for syntax habits/tastes... probably not worth it. Note that in your special case you could also use sed and a regular _expression_ as your own preprocessor.
gael
Aron Ahmadia wrote:
Hi Jinglei,
I'm wondering if it's possible to use array(i:j)
Nope. The : isn't a reserved operator in C++, so for you to use an
_expression_ like array(i:j), the best thing you could do would be to
write your own preprocessor that automagically takes expressions of
that form and translates them to array.segment(i,j)
David Bindel (Cornell) has a piece of software that does similar (but
not what you want) preprocessing work for constant matrices:
http://www.cs.cornell.edu/~bindel/cims/matexpr/
However, my recommendation is that you just stick with the Eigen API
unless you want to spend three days learning a parsing tool like YACC
to do what you want.
Warm Regards,
Aron Ahmadia
On Fri, Feb 5, 2010 at 1:53 PM, Jinglei Hu <jingleihu@xxxxxxxxx> wrote:
Hi guys,
I knew from the Eigen developer that one can use array.segment(i, j) to get
slice of an array. I'm wondering if it's possible to use array(i:j) to get
slice just like Fortran.
Cheers,
Jinglei