freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pooma-dev] How to apply a functor to ET leafs


From: Richard Guenther
Subject: Re: [pooma-dev] How to apply a functor to ET leafs
Date: Mon, 28 Oct 2002 14:39:34 +0100 (CET)

On Mon, 28 Oct 2002, Richard Guenther wrote:

> Hi!
>
> I'd like to apply a functor to the parts of an expression and view
> the result as an expression. I suspect I can do this somehow using
> forEach(), but before I dig too far, I just ask if somebody knows
> the answer already. Take
>
>   Field_t A, B, C;
>   Interval I;
>
>   C(I) = forEach(A*B, evalAt(0.5), ?)(I);
>
> which should "evaluate" A and B at 0.5 and then just apply the usual
> expression for interval I.

To follow up myself I created

struct evalAt {
  evalAt(double x) : x_m(x) {}
  const double x_m;
};

template <class T>
struct LeafFunctor<T, evalAt >
{
  typedef double Type_t;
  inline static Type_t apply(const T &p, const evalAt &x)
  {
    return peval(p, x.x_m);
  }
};

and use now

  C(I) = forEach((A*B).engine().expression(), evalAt(0.5), TreeCombine())(I);

but of course I cannot take a view of an expression. So how do I
re-construct a Field<,, ExpressionTag<>> from the forEach result? It needs
to match the A*B expression obviously. Also just using

  C(I) = forEach((A(I)*B(I)).engine().expression(), evalAt(0.5), TreeCombine());

doesnt work, as evalAt gets called with Field<> as T, not with the actual
elements it seems.

I'm lost here, Richard.

--
Richard Guenther <address@hidden>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
The GLAME Project: http://www.glame.de/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]