Boost logo

Proto :

Subject: Re: [proto] Manipulating an expression tree
From: Karsten Ahnert (karsten.ahnert_at_[hidden])
Date: 2011-04-08 04:56:57


>>> If you need to compute intermediate values, you can use a transform to
>>> build a parallel structure.
>>
>> Do you mean to build an entire new tree, or just to replace some nodes?
>
> If only some nodes have associated intermediate result, then you could
> just replace some nodes.

Ok, this is a clear hint.

>> In my current algorithm I use callable contexts to do the work. I think
>> this is more favorable since I have to evaluate the tree N times to
>> obtain
>> the result.
>
> Why does that matter? Transforms are almost always a better choice.
>
>> I think it would be nice to replace some nodes and customizing
>> the evaluation context, such that these nodes can be used to store the
>> intermediates.
>
> If you're doing calculation *and* tree transformation, then drop the
> callable contexts. They can't do the job.

First I do tree transformation and then calculation. A Callable context
will not do the job, since one only gets the tag of the current node, but
not the node itself. So I have to implement my own context.

I am not sure if transforms can do that job. It is definitely not possible
to obtain the full tree for 10th derivative. Maybe some other tricks are
possible with transforms. At the moment I don't understand them in detail,
but I will try to change this. Thanks for your advice.


Proto list run by eric at boostpro.com