Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Functor.C
Go to the documentation of this file.
1#include<TRInterface.h>
2#include<TMath.h>
3
5
7public:
9 f=TMath::BesselY1;//here is the function that I want.
10 }
12 return f(x);
13 }
14private:
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 ROOTR_MODULE
Definition RExports.h:162
#define LOAD_ROOTR_MODULE(NAME)
Definition RExports.h:176
double Double_t
Definition RtypesCore.h:59
Double_t(* Function)(Double_t)
Definition Functor.C:4
void Functor()
Definition Functor.C:26
Double_t doEval(Double_t x)
Definition Functor.C:11
MyFunctor()
Definition Functor.C:8
Function f
Definition Functor.C:15
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
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:1714