Lambda functions to create a TF2

Hello.
It is great to use lambda functions to create a TF1 and capture whatever we want.
Not the same possibility for TF2?
Cheers, Ricardo

Hi Ricardo,

Totally (and apologies for the super slow reply…)!

root [0] TF2 f2("f2", [](double* x, double*p) { return x[0] + x[1] * p[0]; }, 0., 1., 0., 1., 1 /*npar*/)
(TF2 &) Name: f2 Title: f2
root [1] f2.SetParameter(0, 1.)
root [2] f2.Eval(1., 2.)
(double) 3.0000000

Cheers, Axel.

Great. Thanks a lot Axel for your response and the example.
If I may suggest, it would be great having this info in ROOT: TF2 Class Reference.
Something like the TF1 page, that pedagogically details the types of functions that can be created.
Snippets are widely appreciated!
Cheers, Ricardo

Hi @rpiegaia ,
I bet @couet or @moneta would accept a pull request in this direction :grinning_face_with_smiling_eyes: Otherwise, they have now been informed of the suggestion!

Cheers,
Enrico

Once it will be approved (and merged) this PR will add this additional example in the TF2 documentation. Thanks

1 Like

PR merged, the new piece of documentation will appear in the reference guide in the next build.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.