Subject: Re: [proto] Manipulating an expression tree
From: Bart Janssens (bart.janssens_at_[hidden])
Date: 2011-04-08 06:03:29
On Thu, Apr 7, 2011 at 12:45 AM, Karsten Ahnert
> Another question is: can a node have a state. In my algorithm it would
> be nice, if every proto::multiplies< > node stores some intermediate
> values which are used during later evaluations of the tree.
I did something similar to this to resolve the issue I had with the
Eigen matrix library. I am replacing multiplies nodes with an
expression that uses proto::extends to add extra state, in this case a
correctly sized matrix to store the temporary matrix Eigen generates.
I've attached the header that does the node replacement in all the
cases that match the WrappableElementExpressions ("Wrap" in the header
means replacing the node). Note that this header is ripped out of the
context of a larger application (used for finite elements), so some
stuff will not make sense, but the general idea might be helpful.
I am using a primitive transform (WrapMatrixExpression) to do the
actual node replacement here. An alternative would be to create a
domain, and then use the make_... family of transforms to create nodes
in that domain. I went for the primitive transform because it seemed
to compile faster and with less memory.
I intend to post a more detailed example on how I solved the problem
with Eigen later on, with examples that are more stand-alone.
Proto list run by eric at boostpro.com