[compute] Define user functions using lambda expressions
Hi, I'm probably missing something obvious, but how would I go about making a custom function using a lambda expression? Say I want to declare some function "sqr" which returns "_1 * _1", and then use this in a transform() lambda expression, ie transform(..., 2.0 * sqr(_1) - 3.0 * _1 + 5.0, ...); to evaluate 2x^2 - 3x + 5. If I try to use BOOST_COMPUTE_FUNCTION() I can't use the resulting function in a lambda expression it seems. Cheers - Asbjørn
On Mon, Dec 22, 2014 at 1:54 PM, Asbjørn
Hi,
I'm probably missing something obvious, but how would I go about making a custom function using a lambda expression? Say I want to declare some function "sqr" which returns "_1 * _1", and then use this in a transform() lambda expression, ie
transform(..., 2.0 * sqr(_1) - 3.0 * _1 + 5.0, ...);
to evaluate 2x^2 - 3x + 5.
If I try to use BOOST_COMPUTE_FUNCTION() I can't use the resulting function in a lambda expression it seems.
Unfortunately, calling user-defined functions from lambda-expressions is not currently supported. See issue #59 [1]. However, this is something I'd like to support, I just haven't had the time to implement it yet. -kyle [1] https://github.com/kylelutz/compute/issues/59
On 22.12.2014 23:51, Kyle Lutz wrote:
On Mon, Dec 22, 2014 at 1:54 PM, Asbjørn
wrote: I'm probably missing something obvious, but how would I go about making a custom function using a lambda expression?
Unfortunately, calling user-defined functions from lambda-expressions is not currently supported. See issue #59 [1].
Ah, doh, sorry for missing the tracker. Not used to projects actually using it for much. I'll have to make do without for now then :) Cheers - Asbjørn
participants (2)
-
Asbjørn
-
Kyle Lutz