
On Aug 3, 11:35 am, Steven Watanabe <watanab...@gmail.com> wrote:
AMDG Phoenixallows lazy functions like this
struct first_moment_type { typedef double result_type; double operator()(double arg) { return x; }
};
phoenix::function<first_moment_type> first_moment;
Thanks as always Steven, What is the general thinking on lambda vs. phoenix 2 vs. phoenix 3? Do we expect phoenix 3 to be the main lambda library in boost (eventually)? Should I start getting comfortable with Phoenix 2 to prepare for it or might Phoenix 3 be radically different? Also, I can't figure out in phoenix how I would have lazy operator() on already constructed functors. Is this possible? The main use case of this is to use an expectation operator over an interpolator: -------------------------------------------- template<typename F, typename Distribution> double expectation(F f, Distribution dist){ //Integrates f using dist over its entire support. //... monte carlo, quadrature, etc. } class linear_interpolator{ //construction, etc. double operator()(double x){....} }; //How to make operator() lazy here? I could modify linear interpolator itself if that helps. struct g_type { typedef double result_type; double operator()(double arg) { return x; } }; phoenix::function<first_moment_type> g; //User code linear_interpolator f(....); boost::math::normal_distribution dist(0,1); using namespace boost::phoenix; actor<argument<0> > const _x= argument<0>(); //dummy integration variable cout << expectation( f( _x), dist); //And the main reason I want everything lazy is to allow this which maps //the mathematical models I deal with. cout << expectation( f( g(_x) ), dist); Thanks, -Jesse