Logo ROOT   6.14/05
Reference Guide
Functor.C
Go to the documentation of this file.
1 #include<TRInterface.h>
2 #include<TMath.h>
3 
5 
6 class MyFunctor{
7 public:
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  }
14 private:
15  Function f;
16 };
17 
18 ROOTR_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 
26 void 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 }
void Functor()
Definition: Functor.C:26
#define f(i)
Definition: RSha256.hxx:104
ROOTR_MODULE(MyFunctorModule)
Definition: Functor.C:18
Double_t BesselY1(Double_t x)
Bessel function Y0(x) for positive x.
Double_t x[n]
Definition: legend1.C:17
ROOT::R::TRInterface & r
Definition: Object.C:4
Double_t(* Function)(Double_t)
Definition: Functor.C:4
double Double_t
Definition: RtypesCore.h:55
static TRInterface & Instance()
static method to get an TRInterface instance reference
#define LOAD_ROOTR_MODULE(NAME)
Definition: RExports.h:172