Logo ROOT   6.18/05
Reference Guide
Functor.C
Go to the documentation of this file.
1#include<TRInterface.h>
2#include<TMath.h>
3
5
6class MyFunctor{
7public:
8 MyFunctor(){
9 f=TMath::BesselY1;//here is the function that I want.
10 }
11 Double_t doEval(Double_t x) {
12 return f(x);
13 }
14private:
15 Function f;
16};
17
18ROOTR_MODULE(MyFunctorModule) {
19 ROOT::R::class_<MyFunctor>( "MyFunctor" )
20 .constructor()
21 .method( "doEval", &MyFunctor::doEval )
22// .method( "otherMethod", &MyFunctor::otherMethod )//you can added more methods adding .method(name,pointer)
23 ;
24}
25
26void Functor()
27{
29 r["MyFunctorModule"]<<LOAD_ROOTR_MODULE(MyFunctorModule);
30
31 r<<"MyFunctor <- MyFunctorModule$MyFunctor";
32 r<<"u <- new(MyFunctor)";
33 r<<"print(u$doEval( 1 ))";
34 std::cout<<"value in ROOT = "<<TMath::BesselY1(1)<<std::endl;
35}
ROOT::R::TRInterface & r
Definition: Object.C:4
#define LOAD_ROOTR_MODULE(NAME)
Definition: RExports.h:177
#define f(i)
Definition: RSha256.hxx:104
double Double_t
Definition: RtypesCore.h:55
Double_t(* Function)(Double_t)
Definition: Functor.C:4
void Functor()
Definition: Functor.C:26
ROOTR_MODULE(MyFunctorModule)
Definition: Functor.C:18
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
Definition: TRInterface.h:137
static TRInterface & Instance()
static method to get an TRInterface instance reference
Double_t x[n]
Definition: legend1.C:17
Double_t BesselY1(Double_t x)
Bessel function Y0(x) for positive x.
Definition: TMath.cxx:1721