From 352d480b40a15ec7f030d67354baa217546bc273 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sat, 16 May 2015 00:34:48 -0500 Subject: [PATCH 01/21] ROOTR: fixed TRDataFrame to support operators on Linux --- bindings/r/inc/TRInterface.h | 11 +++++++++++ bindings/r/src/TRInterface.cxx | 11 +++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bindings/r/inc/TRInterface.h b/bindings/r/inc/TRInterface.h index 7334521ba6419..bc944a6880ae3 100644 --- a/bindings/r/inc/TRInterface.h +++ b/bindings/r/inc/TRInterface.h @@ -81,6 +81,16 @@ namespace ROOT { fInterface->Assign(fun, fName); return *this; } + + Binding &operator=(const TRDataFrame &df) { + fInterface->Assign(df, fName); + return *this; + } + + Binding &operator<<(const TRDataFrame &df) { + fInterface->Assign(df, fName); + return *this; + } template Binding &operator >>(T &var) { var = fInterface->Eval(fName).As(); @@ -122,6 +132,7 @@ namespace ROOT { fR->assign(var, name.Data()); } void Assign(const TRFunction &fun, const TString &name); + void Assign(const TRDataFrame &df, const TString &name); void Interactive(); void ProcessEventsLoop(); diff --git a/bindings/r/src/TRInterface.cxx b/bindings/r/src/TRInterface.cxx index 8ab57d0b45f92..c85c63b0c404f 100644 --- a/bindings/r/src/TRInterface.cxx +++ b/bindings/r/src/TRInterface.cxx @@ -190,7 +190,7 @@ Int_t TRInterface::Eval(const TString &code, TRObjectProxy &ans) // Parse R code and returns status of execution. // the RObject's response is saved in ans SEXP fans; - Int_t rc; + Int_t rc=kFALSE; try{ rc = fR->parseEval(code.Data(), fans); } @@ -226,7 +226,7 @@ TRObjectProxy TRInterface::Eval(const TString &code) //The RObject result of execution is returned in TRObjectProxy SEXP ans; - int rc; + int rc=kFALSE; try{ rc = fR->parseEval(code.Data(), ans); } @@ -260,6 +260,13 @@ void TRInterface::Assign(const TRFunction &obj, const TString &name) fR->assign(*obj.f, name.Data()); } +//______________________________________________________________________________ +void TRInterface::Assign(const TRDataFrame &obj, const TString &name) +{ + //This method lets you pass c++ functions to R environment. + fR->assign(obj.df, name.Data()); +} + //______________________________________________________________________________ void TRInterface::Interactive() { From af0714f41b91127d6de5c86ce74afbce372e5b38 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sat, 16 May 2015 02:18:13 -0500 Subject: [PATCH 02/21] ROOTR: if TRDataFrame is empty then df["var"]=v create the first column --- bindings/r/inc/TRDataFrame.h | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/bindings/r/inc/TRDataFrame.h b/bindings/r/inc/TRDataFrame.h index 2382519168588..6eca9e1d3aa97 100644 --- a/bindings/r/inc/TRDataFrame.h +++ b/bindings/r/inc/TRDataFrame.h @@ -61,19 +61,25 @@ class TRDataFrame: public TObject { if(found) fDf[fName.Data()]=var; else { - Rcpp::List nDf(size+1); - Rcpp::CharacterVector nnames(size+1); - for(i=0; i Date: Sun, 28 Jun 2015 21:21:23 -0500 Subject: [PATCH 03/21] ROOTR: TRFunction changed to TRFunctionExport that is the class export c++ function to R's environment othar class will be create called TRFunctionImport to call R's function in c++ like c++ functions --- bindings/r/CMakeLists.txt | 2 +- bindings/r/inc/LinkDef.h | 2 +- bindings/r/inc/RExports.h | 2 +- .../r/inc/{TRFunction.h => TRFunctionExport.h} | 18 +++++++++--------- bindings/r/inc/TRInterface.h | 10 +++++----- bindings/r/src/RExports.cxx | 2 +- .../{TRFunction.cxx => TRFunctionExport.cxx} | 18 +++++++++--------- bindings/r/src/TRInterface.cxx | 2 +- math/rtools/src/RMinimizer.cxx | 4 ++-- 9 files changed, 30 insertions(+), 30 deletions(-) rename bindings/r/inc/{TRFunction.h => TRFunctionExport.h} (78%) rename bindings/r/src/{TRFunction.cxx => TRFunctionExport.cxx} (88%) diff --git a/bindings/r/CMakeLists.txt b/bindings/r/CMakeLists.txt index ec2144dda34cf..8d1aea467eae7 100644 --- a/bindings/r/CMakeLists.txt +++ b/bindings/r/CMakeLists.txt @@ -11,7 +11,7 @@ include_directories(${R_INCLUDE_DIRS}) set(R_HEADERS ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRInterface.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRObjectProxy.h - ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRFunction.h + ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRFunctionExport.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRInternalFunction.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRDataFrame.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/RExports.h) diff --git a/bindings/r/inc/LinkDef.h b/bindings/r/inc/LinkDef.h index 9a4b5de18b58b..33eb448cfbba2 100644 --- a/bindings/r/inc/LinkDef.h +++ b/bindings/r/inc/LinkDef.h @@ -19,7 +19,7 @@ #pragma link C++ nestedtypedef; //classes -#pragma link C++ class ROOT::R::TRFunction+; +#pragma link C++ class ROOT::R::TRFunctionExport+; #pragma link C++ class ROOT::R::TRInterface+; diff --git a/bindings/r/inc/RExports.h b/bindings/r/inc/RExports.h index dca5a0f91045e..4b75f5f331c05 100644 --- a/bindings/r/inc/RExports.h +++ b/bindings/r/inc/RExports.h @@ -64,7 +64,7 @@ #include namespace ROOT { namespace R { - class TRFunction; + class TRFunctionExport; class TRDataFrame; class TRObjectProxy; } diff --git a/bindings/r/inc/TRFunction.h b/bindings/r/inc/TRFunctionExport.h similarity index 78% rename from bindings/r/inc/TRFunction.h rename to bindings/r/inc/TRFunctionExport.h index f35696f8c9002..f4a08499e252f 100644 --- a/bindings/r/inc/TRFunction.h +++ b/bindings/r/inc/TRFunctionExport.h @@ -3,14 +3,14 @@ /************************************************************************* - * Copyright (C) 2013-2014, Omar Andres Zapata Mesa * + * Copyright (C) 2013-2015, Omar Andres Zapata Mesa * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ -#ifndef ROOT_R_TRFunction -#define ROOT_R_TRFunction +#ifndef ROOT_R_TRFunctionExport +#define ROOT_R_TRFunctionExport #ifndef ROOT_R_TRInternalFunction #include @@ -28,17 +28,17 @@ namespace ROOT { namespace R { class TRInterface; - class TRFunction: public TObject { + class TRFunctionExport: public TObject { friend class TRInterface; - friend SEXP Rcpp::wrap(const TRFunction &f); + friend SEXP Rcpp::wrap(const TRFunctionExport &f); protected: TRInternalFunction *f; public: - TRFunction(); + TRFunctionExport(); - TRFunction(const TRFunction &fun); + TRFunctionExport(const TRFunctionExport &fun); //________________________________________________________________________________________________________ - template TRFunction(T fun) { + template TRFunctionExport(T fun) { //template constructor that supports a lot // of function's prototypes f = new TRInternalFunction(fun); @@ -51,7 +51,7 @@ namespace ROOT { f = new TRInternalFunction(fun); } - ClassDef(TRFunction, 0) // + ClassDef(TRFunctionExport, 0) // }; } } diff --git a/bindings/r/inc/TRInterface.h b/bindings/r/inc/TRInterface.h index bc944a6880ae3..2c4643ab25cfa 100644 --- a/bindings/r/inc/TRInterface.h +++ b/bindings/r/inc/TRInterface.h @@ -20,8 +20,8 @@ #include #endif -#ifndef ROOT_R_TFunction -#include +#ifndef ROOT_R_TFunctionExport +#include #endif #ifndef ROOT_TThread @@ -70,13 +70,13 @@ namespace ROOT { fInterface->Assign(data, fName); return *this; } - Binding &operator=(const TRFunction &fun) { + Binding &operator=(const TRFunctionExport &fun) { //The method assign is not a template for a function fInterface->Assign(fun, fName); return *this; } - Binding &operator<<(const TRFunction &fun) { + Binding &operator<<(const TRFunctionExport &fun) { //The method assign is not a template for a function fInterface->Assign(fun, fName); return *this; @@ -131,7 +131,7 @@ namespace ROOT { // the TString's name is the name of the variable in the R enviroment. fR->assign(var, name.Data()); } - void Assign(const TRFunction &fun, const TString &name); + void Assign(const TRFunctionExport &fun, const TString &name); void Assign(const TRDataFrame &df, const TString &name); void Interactive(); diff --git a/bindings/r/src/RExports.cxx b/bindings/r/src/RExports.cxx index 7c470854c3dae..37eeb7e920f21 100644 --- a/bindings/r/src/RExports.cxx +++ b/bindings/r/src/RExports.cxx @@ -6,7 +6,7 @@ * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #include -#include +#include #include #include #include diff --git a/bindings/r/src/TRFunction.cxx b/bindings/r/src/TRFunctionExport.cxx similarity index 88% rename from bindings/r/src/TRFunction.cxx rename to bindings/r/src/TRFunctionExport.cxx index ef749749d2f03..9fbaa4aff1595 100644 --- a/bindings/r/src/TRFunction.cxx +++ b/bindings/r/src/TRFunctionExport.cxx @@ -1,17 +1,17 @@ /************************************************************************* - * Copyright (C) 2013-2014, Omar Andres Zapata Mesa * + * Copyright (C) 2013-2015, Omar Andres Zapata Mesa * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ -#include +#include //______________________________________________________________________________ /* Begin_Html -

TRFunction class

+

TRFunctionExport class

-The TRFunction class lets you pass ROOT's functions to R's environment
+The TRFunctionExport class lets you pass ROOT's functions to R's environment

The next example was based in
@@ -75,10 +75,10 @@ void Minimization() { ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); //passing RosenBrock function to R - r["RosenBrock"]<assign(*obj.f, name.Data()); diff --git a/math/rtools/src/RMinimizer.cxx b/math/rtools/src/RMinimizer.cxx index e5b2f3c0d0358..5880ee03931e0 100644 --- a/math/rtools/src/RMinimizer.cxx +++ b/math/rtools/src/RMinimizer.cxx @@ -56,8 +56,8 @@ namespace ROOT { //pass functions and variables to R ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - r["minfunction"] = ROOT::R::TRFunction((minfunction)); - r["mingradfunction"] = ROOT::R::TRFunction((mingradfunction)); + r["minfunction"] = ROOT::R::TRFunctionExport((minfunction)); + r["mingradfunction"] = ROOT::R::TRFunctionExport((mingradfunction)); r["method"] = fMethod.c_str(); std::vector stepSizes(StepSizes(), StepSizes()+NDim()); std::vector values(X(), X()+NDim()); From 2f98d0b000752bf65cffec8eaf15d2e299625618 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sun, 28 Jun 2015 23:12:14 -0500 Subject: [PATCH 04/21] ROOTR: added TRFunctionImport, now you can call R's fucntion from c++ very easy --- bindings/r/CMakeLists.txt | 1 + bindings/r/inc/LinkDef.h | 2 + bindings/r/inc/TRFunctionImport.h | 62 +++++++++++++ bindings/r/inc/TRFunctionImport__oprtr.h | 113 +++++++++++++++++++++++ bindings/r/src/TRFunctionImport.cxx | 51 ++++++++++ bindings/r/tests/Functions.C | 55 +++++++---- 6 files changed, 264 insertions(+), 20 deletions(-) create mode 100644 bindings/r/inc/TRFunctionImport.h create mode 100644 bindings/r/inc/TRFunctionImport__oprtr.h create mode 100644 bindings/r/src/TRFunctionImport.cxx diff --git a/bindings/r/CMakeLists.txt b/bindings/r/CMakeLists.txt index 8d1aea467eae7..1d1c8a7c9bdee 100644 --- a/bindings/r/CMakeLists.txt +++ b/bindings/r/CMakeLists.txt @@ -12,6 +12,7 @@ include_directories(${R_INCLUDE_DIRS}) set(R_HEADERS ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRInterface.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRObjectProxy.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRFunctionExport.h + ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRFunctionImport.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRInternalFunction.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRDataFrame.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/RExports.h) diff --git a/bindings/r/inc/LinkDef.h b/bindings/r/inc/LinkDef.h index 33eb448cfbba2..ea5f82be76edf 100644 --- a/bindings/r/inc/LinkDef.h +++ b/bindings/r/inc/LinkDef.h @@ -21,6 +21,8 @@ //classes #pragma link C++ class ROOT::R::TRFunctionExport+; +#pragma link C++ class ROOT::R::TRFunctionImport+; + #pragma link C++ class ROOT::R::TRInterface+; #pragma link C++ class ROOT::R::TRObjectProxy+; diff --git a/bindings/r/inc/TRFunctionImport.h b/bindings/r/inc/TRFunctionImport.h new file mode 100644 index 0000000000000..56f153c7d45f7 --- /dev/null +++ b/bindings/r/inc/TRFunctionImport.h @@ -0,0 +1,62 @@ +// @(#)root/r:$Id$ +// Author: Omar Zapata 28/06/2015 + + +/************************************************************************* + * Copyright (C) 2015, Omar Andres Zapata Mesa * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ +#ifndef ROOT_R_TRFunctionImport +#define ROOT_R_TRFunctionImport + + +#ifndef ROOT_R_RExports +#include +#endif + +#ifndef ROOT_R_TRObjectProxy +#include +#endif + +#ifndef Rcpp_hpp +#include +#endif + +//________________________________________________________________________________________________________ +/** + This is a base class to pass functions from ROOT to R + + + @ingroup R +*/ + +namespace ROOT { + namespace R { + + class TRInterface; + class TRFunctionImport: public TObject { + friend class TRInterface; + friend SEXP Rcpp::wrap(const TRFunctionImport &f); + protected: + Rcpp::Function *f; + TString fFunctionName; + TString fNameSpace; + + public: + TRFunctionImport(const TString& name); + TRFunctionImport(const TString& name, const TString& ns); + TRFunctionImport(const TRFunctionImport &fun); + ~TRFunctionImport(){if(f) delete f;} + TRObjectProxy operator()(){return (*f)();} + #include + ClassDef(TRFunctionImport, 0) // + }; + } +} + + + +#endif diff --git a/bindings/r/inc/TRFunctionImport__oprtr.h b/bindings/r/inc/TRFunctionImport__oprtr.h new file mode 100644 index 0000000000000..86c4676fe985a --- /dev/null +++ b/bindings/r/inc/TRFunctionImport__oprtr.h @@ -0,0 +1,113 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +// +// TRFunctionImport__oprt.h: based in Rcpp R/C++ interface class library -- generated helper code for Function.h +// +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Modified by Omar Zapata for ROOTR +// +// This file is based in Rcpp. + +#ifndef ROOT_R_TRFunctionImport_oprtr +#define ROOT_R_TRFunctionImport_oprtr + + template + TRObjectProxy operator()(const T1& t1) const { + return (*f)(t1) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2) const { + return (*f)(t1, t2) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3) const { + return (*f)(t1, t2, t3) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4) const { + return (*f)(t1, t2, t3, t4) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) const { + return (*f)(t1, t2, t3, t4, t5) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) const { + return (*f)(t1, t2, t3, t4, t5, t6) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19) ; + } + + template + TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19, const T20& t20) const { + return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) ; + } + +#endif diff --git a/bindings/r/src/TRFunctionImport.cxx b/bindings/r/src/TRFunctionImport.cxx new file mode 100644 index 0000000000000..3ff4bc3e7964f --- /dev/null +++ b/bindings/r/src/TRFunctionImport.cxx @@ -0,0 +1,51 @@ +/************************************************************************* + * Copyright (C) 2015, Omar Andres Zapata Mesa * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ +#include + +#ifndef Rcpp_Function_h +#include +#endif + +//______________________________________________________________________________ +/* Begin_Html +

TRFunctionImport class

+ +

+The TRFunctionImport class lets you call R's functions to ROOT's environment
+

+End_Html +*/ + + +using namespace ROOT::R; +ClassImp(TRFunctionImport) + + + +//______________________________________________________________________________ +TRFunctionImport::TRFunctionImport(const TRFunctionImport &fun): TObject(fun) +{ + fFunctionName=fun.fFunctionName; + fNameSpace=fun.fNameSpace; + f = fun.f; +} + +//______________________________________________________________________________ +TRFunctionImport::TRFunctionImport(const TString& name) +{ + fFunctionName=name; + f=new Rcpp::Function(name.Data()); +} + +//______________________________________________________________________________ +TRFunctionImport::TRFunctionImport(const TString& name, const TString& ns) +{ + fFunctionName=name; + fNameSpace=ns; + f=new Rcpp::Function(name.Data(),ns.Data()); +} diff --git a/bindings/r/tests/Functions.C b/bindings/r/tests/Functions.C index 9bd076a12255c..408a9499b4e76 100644 --- a/bindings/r/tests/Functions.C +++ b/bindings/r/tests/Functions.C @@ -16,7 +16,7 @@ void funs(TString s) std::cout << "hello " << s.Data() << std::endl; } -//this prototype dont work because argument should be +//this prototype dont work because argument should be //an object to pass an array. Double_t fun3(Double_t *x, Double_t *par) { @@ -29,33 +29,48 @@ Double_t fun4(Double_t x) } -void Functions() +void Functions(TString type = "Import") { - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); + ROOT::R::TRInterface &r = ROOT::R::TRInterface::Instance(); r.SetVerbose(kFALSE); + if (type == "Export") { + std::cout << "-----------------------" << std::endl; + std::cout << "Testing FunctionExport" << std::endl; + std::cout << "-----------------------" << std::endl; + r["funv"] << ROOT::R::TRFunctionExport(funv); + r << "print(funv(c(2,3)))"; - r["funv"]< Date: Mon, 29 Jun 2015 04:38:36 -0500 Subject: [PATCH 05/21] ROOTR: ->removed unneeded code -> added method AsMatrix and Print in TRDataFrame --- bindings/r/CMakeLists.txt | 5 -- bindings/r/inc/RExports.h | 8 +- bindings/r/inc/TRCanvas.h | 68 ----------------- bindings/r/inc/TRDataFrame.h | 24 ++++++ bindings/r/inc/TRF1.h | 88 ---------------------- bindings/r/inc/TRFile.h | 92 ----------------------- bindings/r/inc/TRFunctionImport.h | 2 +- bindings/r/inc/TRFunctionImport__oprtr.h | 40 +++++----- bindings/r/inc/TRGraph.h | 66 ---------------- bindings/r/inc/TRRint.h | 59 --------------- bindings/r/inc/TRSystem.h | 96 ------------------------ bindings/r/tests/DataFrame.C | 7 ++ bindings/r/tests/Functions.C | 2 + 13 files changed, 60 insertions(+), 497 deletions(-) delete mode 100644 bindings/r/inc/TRCanvas.h delete mode 100644 bindings/r/inc/TRF1.h delete mode 100644 bindings/r/inc/TRFile.h delete mode 100644 bindings/r/inc/TRGraph.h delete mode 100644 bindings/r/inc/TRRint.h delete mode 100644 bindings/r/inc/TRSystem.h diff --git a/bindings/r/CMakeLists.txt b/bindings/r/CMakeLists.txt index 1d1c8a7c9bdee..db4abffae92e7 100644 --- a/bindings/r/CMakeLists.txt +++ b/bindings/r/CMakeLists.txt @@ -16,11 +16,6 @@ set(R_HEADERS ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRInterface.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRInternalFunction.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRDataFrame.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/RExports.h) -set(RHIST_HEADERS ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRF1.h - ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRGraph.h) -set(ROI_HEADERS ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRFile.h) -set(RGPAD_HEADERS ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRCanvas.h) -set(RRINT_HEADERS ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRRint.h) SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) ROOT_GENERATE_DICTIONARY(G__RInterface ${R_HEADERS} MODULE ${libname} LINKDEF LinkDef.h) diff --git a/bindings/r/inc/RExports.h b/bindings/r/inc/RExports.h index 4b75f5f331c05..5a3e8675aa0ac 100644 --- a/bindings/r/inc/RExports.h +++ b/bindings/r/inc/RExports.h @@ -24,8 +24,8 @@ #include #endif -#ifndef ROOT_TMatrix -#include +#ifndef ROOT_TMatrixT +#include #endif #ifndef ROOT_TArrayD @@ -61,6 +61,10 @@ #endif +//Some useful typedefs +typedef std::vector TVectorString; + + #include namespace ROOT { namespace R { diff --git a/bindings/r/inc/TRCanvas.h b/bindings/r/inc/TRCanvas.h deleted file mode 100644 index d97868f08afb3..0000000000000 --- a/bindings/r/inc/TRCanvas.h +++ /dev/null @@ -1,68 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata 26/05/2014 - - -/************************************************************************* - * Copyright (C) 2014, Omar Andres Zapata Mesa * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#ifndef ROOT_R_TCanvas -#define ROOT_R_TCanvas - -#ifndef ROOT_R_RExports -#include -#endif - -#ifndef ROOT_TCanvas -#include -#endif - -//________________________________________________________________________________________________________ -/** - This is TCanvas class for R - - - @ingroup R -*/ - -namespace ROOT { - namespace R { - - class TRCanvas: public TCanvas { - public: - TRCanvas(); - TRCanvas(TString name):TCanvas(name.Data(), "", 1){} - TRCanvas(TString name,TString tittle):TCanvas(name.Data(), tittle.Data(), 1){} - TRCanvas(TString name,TString tittle,Int_t form):TCanvas(name.Data(), tittle.Data(), form){} - ~TRCanvas() {}; - - void Draw(){TCanvas::Draw();} - void Draw(TString opt){TCanvas::Draw(opt.Data());} - void Write(TString a, Int_t b, Int_t c){TCanvas::Write(a.Data(),b,c);} - }; - } - - -} -ROOTR_EXPOSED_CLASS_INTERNAL(TRCanvas) - - -ROOTR_MODULE(ROOTR_TRCanvas) -{ - - ROOT::R::class_("TRCanvas", "A Canvas is an area mapped to a window directly under the control of the display manager. ") - .constructor() - .constructor() - .constructor() - .method("Draw", (void (ROOT::R::TRCanvas::*)())(&ROOT::R::TRCanvas::Draw)) - .method("Draw", (void (ROOT::R::TRCanvas::*)(TString))(&ROOT::R::TRCanvas::Draw)) - .method("Divide", (void (ROOT::R::TRCanvas::*)(Int_t, Int_t, Float_t, Float_t, Int_t))(&ROOT::R::TRCanvas::Divide)) - .method("Write", (Int_t(ROOT::R::TRCanvas::*)(TString , Int_t, Int_t))(&ROOT::R::TRCanvas::Write)) - .method("Update", (void(ROOT::R::TRCanvas::*)())(&ROOT::R::TRCanvas::Update)) - ; -} - -#endif diff --git a/bindings/r/inc/TRDataFrame.h b/bindings/r/inc/TRDataFrame.h index 6eca9e1d3aa97..f167c30215358 100644 --- a/bindings/r/inc/TRDataFrame.h +++ b/bindings/r/inc/TRDataFrame.h @@ -20,6 +20,10 @@ #include #endif +#ifndef ROOT_R_TRFunctionImport +#include +#endif + //________________________________________________________________________________________________________ /** This is a base class to create DataFrames from ROOT to R @@ -187,6 +191,26 @@ class TRDataFrame: public TObject { } int GetNcols(){return df.size();} int GetNrows(){return df.nrows();} + TVectorString GetColNames() + { + Rcpp::CharacterVector names=df.attr("names"); + TVectorString rnames(GetNcols()); + for(int i=0;i TMatrixT AsMatrix() + { + TRFunctionImport asMatrix("as.matrix"); + return Rcpp::as >(asMatrix(df)); + } + + void Print(TString label="") + { + TRFunctionImport print("print"); + if(label=="") print(df); + else print(df[label.Data()]); + } ClassDef(TRDataFrame, 0) // }; } diff --git a/bindings/r/inc/TRF1.h b/bindings/r/inc/TRF1.h deleted file mode 100644 index 4d8710f9a5e60..0000000000000 --- a/bindings/r/inc/TRF1.h +++ /dev/null @@ -1,88 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata 26/05/2014 - - -/************************************************************************* - * Copyright (C) 2014, Omar Andres Zapata Mesa * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#ifndef ROOT_R_TRF1 -#define ROOT_R_TRF1 - -#ifndef ROOT_TF1 -#include -#endif - -#ifndef ROOT_R_RExports -#include -#endif - -//________________________________________________________________________________________________________ -/** - This is TF1's wrapper class for R - - - @ingroup R -*/ - -namespace ROOT { - namespace R { - class TRF1: public TF1 { - public: - TRF1():TF1(){} - TRF1(const TF1 &f1): TF1(f1) {} - TRF1(TString name, TString formula, Double_t xmin = 0, Double_t xmax = 1):TF1(name.Data(), formula.Data(), xmin, xmax){} - std::vector Eval(std::vector x); - void Draw(){TF1::Draw();} - void Draw(TString opt){TF1::Draw(opt.Data());} - inline Int_t Write(const TString name) { - return TF1::Write(name.Data()); - } - inline Int_t Write(const TString name, Int_t option,Int_t bufsize) { - return TF1::Write(name.Data(),option,bufsize); - } - }; - } -} - -namespace Rcpp { - template<> SEXP wrap(const TF1 &f) - { - return Rcpp::wrap(ROOT::R::TRF1(f)); - } - template<> TF1 as(SEXP f) - { - return Rcpp::as(f); - } -} - -ROOTR_EXPOSED_CLASS_INTERNAL(TRF1) - -//______________________________________________________________________________ -std::vector ROOT::R::TRF1::Eval(std::vector x) -{ - std::vector result(x.size()); - for (unsigned int i = 0; i < x.size(); i++) result[i] = TF1::Eval(x[i]); - return result; -} - - -ROOTR_MODULE(ROOTR_TRF1) -{ - - ROOT::R::class_("TRF1", "1-Dim ROOT's function class") - .constructor() - .method("Eval", (std::vector (ROOT::R::TRF1::*)(std::vector))&ROOT::R::TRF1::Eval) - .method("Eval", (Double_t (ROOT::R::TRF1::*)(Double_t))&ROOT::R::TRF1::Eval) - .method("Draw", (void (ROOT::R::TRF1::*)())(&ROOT::R::TRF1::Draw)) - .method("Draw", (void (ROOT::R::TRF1::*)(TString))(&ROOT::R::TRF1::Draw)) - .method("SetRange", (void (ROOT::R::TRF1::*)(Double_t, Double_t))(&ROOT::R::TRF1::SetRange)) - .method("SetParameter", (void (ROOT::R::TRF1::*)(Int_t, Double_t))(&ROOT::R::TRF1::SetParameter)) - .method("Write", (Int_t(ROOT::R::TRF1::*)(TString, Int_t, Int_t))(&ROOT::R::TRF1::Write)) - .method("Write", (Int_t(ROOT::R::TRF1::*)(TString))(&ROOT::R::TRF1::Write)) - ; -} -#endif diff --git a/bindings/r/inc/TRFile.h b/bindings/r/inc/TRFile.h deleted file mode 100644 index 9f55c22f74b5c..0000000000000 --- a/bindings/r/inc/TRFile.h +++ /dev/null @@ -1,92 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata 5/06/2014 - - -/************************************************************************* - * Copyright (C) 2014, Omar Andres Zapata Mesa * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#ifndef ROOT_R_TRFILE -#define ROOT_R_TRFILE - -#ifndef ROOT_R_RExports -#include -#endif - -#ifndef ROOT_TFile -#include -#endif - -#ifndef ROOT_R_TRF1 -#include -#endif - -#ifndef ROOT_R_TRGraph -#include -#endif - -#ifndef ROOT_R_TRCanvas -#include -#endif - -//________________________________________________________________________________________________________ -/** - This is TFile class for R - - - @ingroup R -*/ -namespace ROOT { - namespace R { - - class TRFile: public TFile { - public: - TRFile():TFile(){} - TRFile(TString fname):TFile(fname.Data()){} - TRFile(TString fname, TString option):TFile(fname.Data(),option.Data()){} - TRFile(TString fname, TString option, TString ftitle):TFile(fname.Data(),option.Data()){} - TRFile(TString fname, TString option, TString ftitle, Int_t compress ); - - template T Get(TString object) { - return *(T *)TFile::Get(object); - } - inline void Close() { - TFile::Close(0); - } - inline void Close(TString opt) { - TFile::Close(opt.Data()); - } - }; - } -} - -//______________________________________________________________________________ -ROOT::R::TRFile::TRFile(TString fname, TString option , TString ftitle, Int_t compress): TFile(fname.Data(), option.Data(), ftitle.Data(), compress) -{ - -} - -ROOTR_MODULE(ROOTR_TRFile) -{ - - ROOT::R::class_("TRFile", "TFile class to manipulate ROOT's files.") - .constructor() - .constructor() - .constructor() - .constructor() - .method("Map", (void (ROOT::R::TRFile::*)())&ROOT::R::TRFile::Map) - .method("ls", (void (ROOT::R::TRFile::*)(TString))&ROOT::R::TRFile::ls) - .method("Flush", (void (ROOT::R::TRFile::*)())&ROOT::R::TRFile::Flush) - .method("Close", (void (ROOT::R::TRFile::*)(TString))&ROOT::R::TRFile::Close) - .method("Close", (void (ROOT::R::TRFile::*)())&ROOT::R::TRFile::Close) - .method("Get", &ROOT::R::TRFile::Get) - .method("Get", &ROOT::R::TRFile::Get) -// .method("Get", &ROOT::R::TRFile::Get)//TRCanvas no supported at the moment - ; -} - - -#endif diff --git a/bindings/r/inc/TRFunctionImport.h b/bindings/r/inc/TRFunctionImport.h index 56f153c7d45f7..b86693bf64f13 100644 --- a/bindings/r/inc/TRFunctionImport.h +++ b/bindings/r/inc/TRFunctionImport.h @@ -50,7 +50,7 @@ namespace ROOT { TRFunctionImport(const TString& name, const TString& ns); TRFunctionImport(const TRFunctionImport &fun); ~TRFunctionImport(){if(f) delete f;} - TRObjectProxy operator()(){return (*f)();} + SEXP operator()(){return (*f)();} #include ClassDef(TRFunctionImport, 0) // }; diff --git a/bindings/r/inc/TRFunctionImport__oprtr.h b/bindings/r/inc/TRFunctionImport__oprtr.h index 86c4676fe985a..cc461dbe9794d 100644 --- a/bindings/r/inc/TRFunctionImport__oprtr.h +++ b/bindings/r/inc/TRFunctionImport__oprtr.h @@ -11,102 +11,102 @@ #define ROOT_R_TRFunctionImport_oprtr template - TRObjectProxy operator()(const T1& t1) const { + SEXP operator()(const T1& t1) const { return (*f)(t1) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2) const { + SEXP operator()(const T1& t1, const T2& t2) const { return (*f)(t1, t2) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3) const { return (*f)(t1, t2, t3) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4) const { return (*f)(t1, t2, t3, t4) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) const { return (*f)(t1, t2, t3, t4, t5) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) const { return (*f)(t1, t2, t3, t4, t5, t6) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) const { return (*f)(t1, t2, t3, t4, t5, t6, t7) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19) ; } template - TRObjectProxy operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19, const T20& t20) const { + SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19, const T20& t20) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) ; } diff --git a/bindings/r/inc/TRGraph.h b/bindings/r/inc/TRGraph.h deleted file mode 100644 index 6b61a697180f8..0000000000000 --- a/bindings/r/inc/TRGraph.h +++ /dev/null @@ -1,66 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata 26/05/2014 - - -/************************************************************************* - * Copyright (C) 2014, Omar Andres Zapata Mesa * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#ifndef ROOT_R_TRGraph -#define ROOT_R_TRGraph - -#ifndef ROOT_TGraph -#include -#endif - -#ifndef ROOT_R_RExports -#include -#endif - -//________________________________________________________________________________________________________ -/** - This is TGraph class for R - - - @ingroup R -*/ - -namespace ROOT { - namespace R { - - class TRGraph: public TGraph { - public: - TRGraph(): TGraph() {}; - TRGraph(const TGraph &g): TGraph(g) {}; - TRGraph(Int_t n, std::vector x, std::vector y): TGraph(n, x.data(), y.data()){} - void Draw(){TGraph::Draw();} - void Draw(TString opt){TGraph::Draw(opt.Data());} - }; - } -} - -namespace Rcpp { - template<> SEXP wrap(const TGraph &f) - { - return Rcpp::wrap(ROOT::R::TRGraph(f)); - } - template<> TGraph as(SEXP f) - { - return Rcpp::as(f); - } -} - -ROOTR_EXPOSED_CLASS_INTERNAL(TRGraph) - -ROOTR_MODULE(ROOTR_TRGraph) -{ - ROOT::R::class_("TRGraph") - .constructor, std::vector >() - .method("Draw", (void (ROOT::R::TRGraph::*)())(&ROOT::R::TRGraph::Draw)) - .method("Draw", (void (ROOT::R::TRGraph::*)(TString))(&ROOT::R::TRGraph::Draw)) - ; -} -#endif diff --git a/bindings/r/inc/TRRint.h b/bindings/r/inc/TRRint.h deleted file mode 100644 index 63bcae6e769b3..0000000000000 --- a/bindings/r/inc/TRRint.h +++ /dev/null @@ -1,59 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata 30/05/2014 - - -/************************************************************************* - * Copyright (C) 2014, Omar Andres Zapata Mesa * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#ifndef ROOT_R_TRRINT -#define ROOT_R_TRRINT - -#ifndef ROOT_R_RExports -#include -#endif - -#ifndef ROOT_TRint -#include -#endif - -//________________________________________________________________________________________________________ -/** - This is TRint class for R - - - @ingroup R -*/ -//NOTE:the arguments for TRint like Int_t*argc and char** is not supported for Rcpp, -//then the class was rewritten -namespace ROOT { - namespace R { - - class TRRint: public TRint { - public: - TRRint(): TRint("ROOTR", 0, 0, 0, 0, kTRUE){} - TRRint(TString name): TRint(name.Data(), 0, 0, 0, 0, kTRUE){} - Long_t ProcessLine(TString line){return TRint::ProcessLine(line.Data());} - TString WorkingDirectory(){return TRint::WorkingDirectory();} - }; - } -} - - -ROOTR_MODULE(ROOTR_TRRint) -{ - - ROOT::R::class_("TRRint", "TRint class to create a ROOT application.") - .constructor() - .constructor() - .method("ProcessLine", (Long_t (ROOT::R::TRRint::*)(TString))&ROOT::R::TRRint::ProcessLine) - .method("Run", (void (ROOT::R::TRRint::*)(Bool_t))&ROOT::R::TRRint::Run) - .method("Terminate", (void (ROOT::R::TRRint::*)(Int_t))&ROOT::R::TRRint::Terminate) - .method("WorkingDirectory", (TString (ROOT::R::TRRint::*)())(&ROOT::R::TRRint::WorkingDirectory)) - ; -} - -#endif diff --git a/bindings/r/inc/TRSystem.h b/bindings/r/inc/TRSystem.h deleted file mode 100644 index ceb18a49a56e6..0000000000000 --- a/bindings/r/inc/TRSystem.h +++ /dev/null @@ -1,96 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata 11/06/2014 - - -/************************************************************************* - * Copyright (C) 2014, Omar Andres Zapata Mesa * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#ifndef ROOT_R_TRSYSTEM -#define ROOT_R_TRSYSTEM - -#ifndef ROOT_R_RExports -#include -#endif - -#ifndef ROOT_TSystem -#include -#endif - -#ifndef ROOT_TThread -#include -#endif - -#ifndef ROOT_TApplication -#include -#endif - -//________________________________________________________________________________________________________ -/** - This is a gSystem wrap for R - - - @ingroup R -*/ -namespace ROOT { - namespace R { - - class TRSystem: public TObject { - private: - TThread *th; - public: - TRSystem(); - ~TRSystem() { - if (th) delete th; - } - void ProcessEventsLoop(); - Int_t Load(TString module); - }; - } -} - -ROOTR_EXPOSED_CLASS_INTERNAL(TRSystem) - - -//______________________________________________________________________________ -ROOT::R::TRSystem::TRSystem(): TObject() -{ - th = nullptr; -} - -//______________________________________________________________________________ -void ROOT::R::TRSystem::ProcessEventsLoop() -{ - if (!gApplication) { - Error("TRSystem", "Running ProcessEventsLoop without global object gApplication."); - return; - } - th = new TThread([](void * args) { - while (kTRUE) { - gSystem->ProcessEvents(); - gSystem->Sleep(100); - } - }, (void *)this); - th->Run(); -} - -//______________________________________________________________________________ -Int_t ROOT::R::TRSystem::Load(TString module) -{ - return gSystem->Load(module.Data()); -} - -ROOTR_MODULE(ROOTR_TRSystem) -{ - - ROOT::R::class_("TRSystem", "TSystem class to manipulate ROOT's Process.") - .constructor() - .method("ProcessEventsLoop", &ROOT::R::TRSystem::ProcessEventsLoop) - .method("Load", (Int_t(ROOT::R::TRSystem::*)(TString))&ROOT::R::TRSystem::Load) - ; -} - -#endif diff --git a/bindings/r/tests/DataFrame.C b/bindings/r/tests/DataFrame.C index 19f6aa7b6562c..bdc7cb60abc54 100644 --- a/bindings/r/tests/DataFrame.C +++ b/bindings/r/tests/DataFrame.C @@ -91,6 +91,13 @@ void DataFrame() { r<<"print(v5)"; + std::cout<<"-----Cast---"<>dfm; + dfm.Print(); + TMatrixT m=dfm.AsMatrix(); + m.Print(); + //Error Handling /* std::cout<<"------------------------------------\n"; try{ diff --git a/bindings/r/tests/Functions.C b/bindings/r/tests/Functions.C index 408a9499b4e76..49e141e3d40b5 100644 --- a/bindings/r/tests/Functions.C +++ b/bindings/r/tests/Functions.C @@ -68,9 +68,11 @@ void Functions(TString type = "Import") print("Hola"); ROOT::R::TRFunctionImport c("c"); + ROOT::R::TRFunctionImport require("require"); ROOT::R::TRObjectProxy vector=c(1,2,3,4); print(vector); + require("C50"); } } From ff3aefc5e3ccb8ba9d8214256917303052ec093a Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Mon, 29 Jun 2015 17:50:56 -0500 Subject: [PATCH 06/21] ROOTR: exported TRFunctionImport using wrap/as from Rcpp --- bindings/r/Module.mk | 12 ++++-------- bindings/r/inc/RExports.h | 6 ++++++ bindings/r/inc/TRFunctionImport.h | 8 ++++++-- bindings/r/inc/TRInterface.h | 4 ++++ bindings/r/src/RExports.cxx | 11 +++++++++++ bindings/r/src/TRFunctionImport.cxx | 5 ----- bindings/r/tests/DataFrame.C | 3 +++ bindings/r/tests/Functions.C | 12 +++++++++++- 8 files changed, 45 insertions(+), 16 deletions(-) diff --git a/bindings/r/Module.mk b/bindings/r/Module.mk index 4bf3f9c00cd14..47d1b6606af3d 100644 --- a/bindings/r/Module.mk +++ b/bindings/r/Module.mk @@ -26,19 +26,15 @@ RDO := $(RDS:.cxx=.o) RDH := $(MODDIRI)/RExports.h \ $(MODDIRI)/TRInterface.h \ $(MODDIRI)/TRObjectProxy.h \ - $(MODDIRI)/TRFunction.h \ + $(MODDIRI)/TRDataFrame.h \ + $(MODDIRI)/TRFunctionImport.h \ + $(MODDIRI)/TRFunctionExport.h \ $(MODDIRI)/TRInternalFunction.h \ $(MODDIRI)/TRInternalFunction__ctors.h -RDHMOD := $(MODDIRI)/TRCanvas.h \ - $(MODDIRI)/TRF1.h \ - $(MODDIRI)/TRRint.h \ - $(MODDIRI)/TRFile.h \ - $(MODDIRI)/TRGraph.h \ - $(MODDIRI)/TRSystem.h -RH := $(RDH) $(RDHMOD) +RH := $(RDH) RS := $(filter-out $(MODDIRS)/G__%,$(wildcard $(MODDIRS)/*.cxx)) RO := $(call stripsrc,$(RS:.cxx=.o)) diff --git a/bindings/r/inc/RExports.h b/bindings/r/inc/RExports.h index 5a3e8675aa0ac..1f62302e07dd7 100644 --- a/bindings/r/inc/RExports.h +++ b/bindings/r/inc/RExports.h @@ -69,6 +69,7 @@ typedef std::vector TVectorString; namespace ROOT { namespace R { class TRFunctionExport; + class TRFunctionImport; class TRDataFrame; class TRObjectProxy; } @@ -103,9 +104,14 @@ namespace Rcpp { template<> SEXP wrap(const ROOT::R::TRDataFrame &o); template<> ROOT::R::TRDataFrame as(SEXP) ; +//TRObjectProxy template<> SEXP wrap(const ROOT::R::TRObjectProxy &o); template<> ROOT::R::TRObjectProxy as(SEXP) ; +//TRFunctionImport + template<> SEXP wrap(const ROOT::R::TRFunctionImport &o); + template<> ROOT::R::TRFunctionImport as(SEXP) ; + template std::array as(SEXP &obj) { std::vector v = Rcpp::as >(obj); diff --git a/bindings/r/inc/TRFunctionImport.h b/bindings/r/inc/TRFunctionImport.h index b86693bf64f13..77bc96a61256e 100644 --- a/bindings/r/inc/TRFunctionImport.h +++ b/bindings/r/inc/TRFunctionImport.h @@ -40,15 +40,19 @@ namespace ROOT { class TRFunctionImport: public TObject { friend class TRInterface; friend SEXP Rcpp::wrap(const TRFunctionImport &f); + friend TRFunctionImport Rcpp::as<>(SEXP); + protected: Rcpp::Function *f; - TString fFunctionName; - TString fNameSpace; + TRFunctionImport(const Rcpp::Function &fun){ + *f=fun; + } public: TRFunctionImport(const TString& name); TRFunctionImport(const TString& name, const TString& ns); TRFunctionImport(const TRFunctionImport &fun); + ~TRFunctionImport(){if(f) delete f;} SEXP operator()(){return (*f)();} #include diff --git a/bindings/r/inc/TRInterface.h b/bindings/r/inc/TRInterface.h index 2c4643ab25cfa..182e8fb70e056 100644 --- a/bindings/r/inc/TRInterface.h +++ b/bindings/r/inc/TRInterface.h @@ -24,6 +24,10 @@ #include #endif +#ifndef ROOT_R_TFunctionImport +#include +#endif + #ifndef ROOT_TThread #include #endif diff --git a/bindings/r/src/RExports.cxx b/bindings/r/src/RExports.cxx index 37eeb7e920f21..9ff20f09e64b4 100644 --- a/bindings/r/src/RExports.cxx +++ b/bindings/r/src/RExports.cxx @@ -90,6 +90,17 @@ namespace Rcpp { { return ROOT::R::TRDataFrame(Rcpp::as(obj)); } + +//TRFunctionImport + template<> SEXP wrap(const ROOT::R::TRFunctionImport &obj) + { + return *obj.f; + } + + template<> ROOT::R::TRFunctionImport as(SEXP obj) + { + return ROOT::R::TRFunctionImport(Rcpp::as(obj)); + } } namespace ROOT { diff --git a/bindings/r/src/TRFunctionImport.cxx b/bindings/r/src/TRFunctionImport.cxx index 3ff4bc3e7964f..82dfb24e24c88 100644 --- a/bindings/r/src/TRFunctionImport.cxx +++ b/bindings/r/src/TRFunctionImport.cxx @@ -30,22 +30,17 @@ ClassImp(TRFunctionImport) //______________________________________________________________________________ TRFunctionImport::TRFunctionImport(const TRFunctionImport &fun): TObject(fun) { - fFunctionName=fun.fFunctionName; - fNameSpace=fun.fNameSpace; f = fun.f; } //______________________________________________________________________________ TRFunctionImport::TRFunctionImport(const TString& name) { - fFunctionName=name; f=new Rcpp::Function(name.Data()); } //______________________________________________________________________________ TRFunctionImport::TRFunctionImport(const TString& name, const TString& ns) { - fFunctionName=name; - fNameSpace=ns; f=new Rcpp::Function(name.Data(),ns.Data()); } diff --git a/bindings/r/tests/DataFrame.C b/bindings/r/tests/DataFrame.C index bdc7cb60abc54..6e01f3e6df530 100644 --- a/bindings/r/tests/DataFrame.C +++ b/bindings/r/tests/DataFrame.C @@ -95,6 +95,9 @@ void DataFrame() { ROOT::R::TRDataFrame dfm; r["df=data.frame(v1=c(0.1,0.2,0.3),v2=c(0.4,0.5,0.6))"]>>dfm; dfm.Print(); + + dfm.Print("v1"); + TMatrixT m=dfm.AsMatrix(); m.Print(); diff --git a/bindings/r/tests/Functions.C b/bindings/r/tests/Functions.C index 49e141e3d40b5..b3faa245e0daa 100644 --- a/bindings/r/tests/Functions.C +++ b/bindings/r/tests/Functions.C @@ -69,10 +69,20 @@ void Functions(TString type = "Import") ROOT::R::TRFunctionImport c("c"); ROOT::R::TRFunctionImport require("require"); + ROOT::R::TRFunctionImport plot("plot"); + ROOT::R::TRFunctionImport devoff("dev.off"); - ROOT::R::TRObjectProxy vector=c(1,2,3,4); + ROOT::R::TRFunctionImport rsin("sin"); + ROOT::R::TRFunctionImport options("options"); + ROOT::R::TRFunctionImport x11("x11"); + options("device='x11'"); + ROOT::R::TRObjectProxy vector=c(1,2,3,4); + x11(); + plot(rsin); +// devoff(); print(vector); + require("C50"); } } From 05b16fe3a155d3cdc793ceedf57a498c69a4352b Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Wed, 1 Jul 2015 19:47:51 -0500 Subject: [PATCH 07/21] ROOTR: working in TRObject, Attr is not working for assignation TRObject c=robj.Attr["someatt"] --- bindings/r/CMakeLists.txt | 2 +- bindings/r/inc/LinkDef.h | 2 +- bindings/r/inc/RExports.h | 8 +- bindings/r/inc/TRDataFrame.h | 12 +- bindings/r/inc/TRFunctionImport.h | 4 +- bindings/r/inc/TRInterface.h | 8 +- bindings/r/inc/TRInterface_Binding.h | 264 +++++++++--------- .../r/inc/{TRObjectProxy.h => TRObject.h} | 52 +++- bindings/r/src/RExports.cxx | 12 +- bindings/r/src/TRInterface.cxx | 10 +- .../r/src/{TRObjectProxy.cxx => TRObject.cxx} | 19 +- bindings/r/tests/Binding.C | 2 +- bindings/r/tests/Functions.C | 30 +- bindings/r/tests/Object.C | 28 ++ math/rtools/src/RMinimizer.cxx | 2 +- 15 files changed, 262 insertions(+), 193 deletions(-) rename bindings/r/inc/{TRObjectProxy.h => TRObject.h} (60%) rename bindings/r/src/{TRObjectProxy.cxx => TRObject.cxx} (74%) create mode 100644 bindings/r/tests/Object.C diff --git a/bindings/r/CMakeLists.txt b/bindings/r/CMakeLists.txt index db4abffae92e7..0afa09d81dbae 100644 --- a/bindings/r/CMakeLists.txt +++ b/bindings/r/CMakeLists.txt @@ -10,7 +10,7 @@ set(libname RInterface) include_directories(${R_INCLUDE_DIRS}) set(R_HEADERS ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRInterface.h - ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRObjectProxy.h + ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRObject.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRFunctionExport.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRFunctionImport.h ${CMAKE_SOURCE_DIR}/bindings/r/inc/TRInternalFunction.h diff --git a/bindings/r/inc/LinkDef.h b/bindings/r/inc/LinkDef.h index ea5f82be76edf..c6a7eb00131f9 100644 --- a/bindings/r/inc/LinkDef.h +++ b/bindings/r/inc/LinkDef.h @@ -25,7 +25,7 @@ #pragma link C++ class ROOT::R::TRInterface+; -#pragma link C++ class ROOT::R::TRObjectProxy+; +#pragma link C++ class ROOT::R::TRObject+; #pragma link C++ class ROOT::R::TRDataFrame+; diff --git a/bindings/r/inc/RExports.h b/bindings/r/inc/RExports.h index 1f62302e07dd7..66134a0d93f2e 100644 --- a/bindings/r/inc/RExports.h +++ b/bindings/r/inc/RExports.h @@ -71,7 +71,7 @@ namespace ROOT { class TRFunctionExport; class TRFunctionImport; class TRDataFrame; - class TRObjectProxy; + class TRObject; } } @@ -104,9 +104,9 @@ namespace Rcpp { template<> SEXP wrap(const ROOT::R::TRDataFrame &o); template<> ROOT::R::TRDataFrame as(SEXP) ; -//TRObjectProxy - template<> SEXP wrap(const ROOT::R::TRObjectProxy &o); - template<> ROOT::R::TRObjectProxy as(SEXP) ; +//TRObject + template<> SEXP wrap(const ROOT::R::TRObject &o); + template<> ROOT::R::TRObject as(SEXP) ; //TRFunctionImport template<> SEXP wrap(const ROOT::R::TRFunctionImport &o); diff --git a/bindings/r/inc/TRDataFrame.h b/bindings/r/inc/TRDataFrame.h index f167c30215358..a6d6d4d69f314 100644 --- a/bindings/r/inc/TRDataFrame.h +++ b/bindings/r/inc/TRDataFrame.h @@ -16,8 +16,8 @@ #include #endif -#ifndef ROOT_R_TRObjectProxy -#include +#ifndef ROOT_R_TRObject +#include #endif #ifndef ROOT_R_TRFunctionImport @@ -78,7 +78,6 @@ class TRDataFrame: public TObject { } nDf[size]=var; nnames[size]=fName.Data(); - nDf.attr("class") = fDf.attr("class") ; nDf.attr("row.names") = fDf.attr("row.names") ; nDf.attr("names") = nnames ; @@ -176,8 +175,10 @@ class TRDataFrame: public TObject { }; TRDataFrame(); + TRDataFrame(SEXP obj){df=Rcpp::as(obj);} TRDataFrame(const TRDataFrame &_df); TRDataFrame(const Rcpp::DataFrame &_df):df(_df){}; + #include Binding operator[](const TString &name); @@ -189,6 +190,11 @@ class TRDataFrame: public TObject { df=obj.df; return *this; } + TRDataFrame& operator=(SEXP obj) { + df=Rcpp::as(obj); + return *this; + } + int GetNcols(){return df.size();} int GetNrows(){return df.nrows();} TVectorString GetColNames() diff --git a/bindings/r/inc/TRFunctionImport.h b/bindings/r/inc/TRFunctionImport.h index 77bc96a61256e..d93110f14f6b6 100644 --- a/bindings/r/inc/TRFunctionImport.h +++ b/bindings/r/inc/TRFunctionImport.h @@ -17,8 +17,8 @@ #include #endif -#ifndef ROOT_R_TRObjectProxy -#include +#ifndef ROOT_R_TRObject +#include #endif #ifndef Rcpp_hpp diff --git a/bindings/r/inc/TRInterface.h b/bindings/r/inc/TRInterface.h index 182e8fb70e056..bb827cec92718 100644 --- a/bindings/r/inc/TRInterface.h +++ b/bindings/r/inc/TRInterface.h @@ -12,8 +12,8 @@ #ifndef ROOT_R_TRInterface #define ROOT_R_TRInterface -#ifndef ROOT_R_TRObjectProxy -#include +#ifndef ROOT_R_TRObject +#include #endif #ifndef ROOT_R_TRDataFrame @@ -120,11 +120,11 @@ namespace ROOT { ~TRInterface(); void SetVerbose(Bool_t status); - Int_t Eval(const TString &code, TRObjectProxy &ans); // parse line, returns in ans; error code rc + Int_t Eval(const TString &code, TRObject &ans); // parse line, returns in ans; error code rc void Execute(const TString &code); - TRObjectProxy Eval(const TString &code); + TRObject Eval(const TString &code); static void LoadModule(TString name); diff --git a/bindings/r/inc/TRInterface_Binding.h b/bindings/r/inc/TRInterface_Binding.h index 4f2d7b77f6df9..efd9deac69e17 100644 --- a/bindings/r/inc/TRInterface_Binding.h +++ b/bindings/r/inc/TRInterface_Binding.h @@ -9,397 +9,397 @@ template Binding &operator=(OUT(*fun)(void)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59, U60 u60)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59, U60 u60, U61 u61)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59, U60 u60, U61 u61, U62 u62)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59, U60 u60, U61 u61, U62 u62, U63 u63)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59, U60 u60, U61 u61, U62 u62, U63 u63, U64 u64)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } //////////////////////////// @@ -408,397 +408,397 @@ Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 template Binding &operator<<(OUT(*fun)(void)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59, U60 u60)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59, U60 u60, U61 u61)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59, U60 u60, U61 u61, U62 u62)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59, U60 u60, U61 u61, U62 u62, U63 u63)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } template Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10, U11 u11, U12 u12, U13 u13, U14 u14, U15 u15, U16 u16, U17 u17, U18 u18, U19 u19, U20 u20, U21 u21, U22 u22, U23 u23, U24 u24, U25 u25, U26 u26, U27 u27, U28 u28, U29 u29, U30 u30, U31 u31, U32 u32, U33 u33, U34 u34, U35 u35, U36 u36, U37 u37, U38 u38, U39 u39, U40 u40, U41 u41, U42 u42, U43 u43, U44 u44, U45 u45, U46 u46, U47 u47, U48 u48, U49 u49, U50 u50, U51 u51, U52 u52, U53 u53, U54 u54, U55 u55, U56 u56, U57 u57, U58 u58, U59 u59, U60 u60, U61 u61, U62 u62, U63 u63, U64 u64)) { - fInterface->Assign(TRFunction(fun), fName); + fInterface->Assign(TRFunctionExport(fun), fName); return *this; } #endif diff --git a/bindings/r/inc/TRObjectProxy.h b/bindings/r/inc/TRObject.h similarity index 60% rename from bindings/r/inc/TRObjectProxy.h rename to bindings/r/inc/TRObject.h index bbaf252128914..0599a2db32793 100644 --- a/bindings/r/inc/TRObjectProxy.h +++ b/bindings/r/inc/TRObject.h @@ -8,8 +8,8 @@ * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ -#ifndef ROOT_R_TRObjectProxy -#define ROOT_R_TRObjectProxy +#ifndef ROOT_R_TRObject +#define ROOT_R_TRObject #ifndef ROOT_R_RExports #include @@ -25,31 +25,53 @@ namespace ROOT { namespace R { - class TRObjectProxy: public TObject { - friend SEXP Rcpp::wrap(const TRObjectProxy &f); + class TRObject: public TObject { + friend SEXP Rcpp::wrap(const TRObject &f); private: - Rcpp::RObject x; + Rcpp::RObject fObj; Bool_t fStatus;//status tell if is a valid object + class Attribute + { + Rcpp::RObject obj; + TString fAttName; + public: + Attribute(){} + void SetObject(Rcpp::RObject o){obj=o;} + + Attribute& operator[](const char* attname) + { + fAttName=attname; + return *this; + } + template RT operator=(T o) + { + obj.attr(fAttName.Data())=o; + return obj; + } + }; public: - TRObjectProxy(): TObject() {}; - TRObjectProxy(SEXP xx); - TRObjectProxy(SEXP xx, Bool_t status); + Attribute Attr; + public: + TRObject(): TObject() {}; + TRObject(SEXP xx); + TRObject(SEXP xx, Bool_t status); void SetStatus(Bool_t status){ fStatus = status;} Bool_t GetStatus() { return fStatus;} - + + void operator=(SEXP xx); - template TRObjectProxy& Wrap(T obj) { - x=::Rcpp::wrap(obj); + template TRObject& Wrap(T obj) { + fObj=::Rcpp::wrap(obj); return *this; } template T As() { if(fStatus) { - T data=::Rcpp::as(x); + T data=::Rcpp::as(fObj); return data; }else { @@ -58,7 +80,7 @@ namespace ROOT { } } - template T operator=(TRObjectProxy &obj) { + template T operator=(TRObject &obj) { return ::Rcpp::as(obj); } @@ -66,7 +88,7 @@ namespace ROOT { if(fStatus) { - T data=::Rcpp::as(x); + T data=::Rcpp::as(fObj); return data; }else { @@ -74,7 +96,7 @@ namespace ROOT { return T(); } } - ClassDef(TRObjectProxy, 0) // + ClassDef(TRObject, 0) // }; } diff --git a/bindings/r/src/RExports.cxx b/bindings/r/src/RExports.cxx index 9ff20f09e64b4..cc39eb24c9ba6 100644 --- a/bindings/r/src/RExports.cxx +++ b/bindings/r/src/RExports.cxx @@ -7,7 +7,7 @@ *************************************************************************/ #include #include -#include +#include #include #include namespace Rcpp { @@ -70,15 +70,15 @@ namespace Rcpp { return TMatrixT(mat.rows(), mat.cols(), &dat[0], "F"); } -//TRObjectProxy - template<> SEXP wrap(const ROOT::R::TRObjectProxy &obj) +//TRObject + template<> SEXP wrap(const ROOT::R::TRObject &obj) { - return obj.x; + return obj.fObj; } - template<> ROOT::R::TRObjectProxy as(SEXP obj) + template<> ROOT::R::TRObject as(SEXP obj) { - return ROOT::R::TRObjectProxy(obj); + return ROOT::R::TRObject(obj); } //TRDataFrame template<> SEXP wrap(const ROOT::R::TRDataFrame &obj) diff --git a/bindings/r/src/TRInterface.cxx b/bindings/r/src/TRInterface.cxx index b60bb39eea5ff..460c20d1477c2 100644 --- a/bindings/r/src/TRInterface.cxx +++ b/bindings/r/src/TRInterface.cxx @@ -25,7 +25,7 @@ The TRInterface class lets you procces R code from ROOT.
You can call R libraries and their functions, plot results in R or ROOT,
and use the power of ROOT and R at the same time.
It also lets you pass scalars, vectors and matrices from ROOT to R
-and from R to ROOT using TRObjectProxy; but you can to use overloaded opetarors [],<< and >>
+and from R to ROOT using TRObject; but you can to use overloaded opetarors [],<< and >>
to work with ROOTR like work with streams of data.
TRInterface class can not be instantiated directly, but you can create objects using the static methods @@ -185,7 +185,7 @@ void TRInterface::LoadModule(TString name) //______________________________________________________________________________ -Int_t TRInterface::Eval(const TString &code, TRObjectProxy &ans) +Int_t TRInterface::Eval(const TString &code, TRObject &ans) { // Parse R code and returns status of execution. // the RObject's response is saved in ans @@ -221,10 +221,10 @@ void TRInterface::Execute(const TString &code) } //______________________________________________________________________________ -TRObjectProxy TRInterface::Eval(const TString &code) +TRObject TRInterface::Eval(const TString &code) { // Execute R code. -//The RObject result of execution is returned in TRObjectProxy +//The RObject result of execution is returned in TRObject SEXP ans; @@ -238,7 +238,7 @@ TRObjectProxy TRInterface::Eval(const TString &code) } catch(...){Error("Eval", "Can execute the requested code: %s",code.Data());} - return TRObjectProxy(ans , (rc == 0) ? kTRUE : kFALSE); + return TRObject(ans , (rc == 0) ? kTRUE : kFALSE); } diff --git a/bindings/r/src/TRObjectProxy.cxx b/bindings/r/src/TRObject.cxx similarity index 74% rename from bindings/r/src/TRObjectProxy.cxx rename to bindings/r/src/TRObject.cxx index b1b6d754978b7..4ec56e66182d1 100644 --- a/bindings/r/src/TRObjectProxy.cxx +++ b/bindings/r/src/TRObject.cxx @@ -5,14 +5,14 @@ * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ -#include +#include #include //______________________________________________________________________________ /* Begin_Html -

TRObjectProxy class

+

TRObject class

-The TRObjectProxy class lets you obtain ROOT's objects from R's objects.
+The TRObject class lets you obtain ROOT's objects from R's objects.
It has some basic template opetarors to convert R's objects into ROOT's datatypes

A simple example
@@ -25,7 +25,7 @@ End_Html void Proxy() { ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -ROOT::R::TRObjectProxy obj; +ROOT::R::TRObject obj; obj=r.ParseEval("seq(1,10)"); TVectorD v=obj; v.Print(); @@ -33,17 +33,18 @@ v.Print(); */ using namespace ROOT::R; -ClassImp(TRObjectProxy) +ClassImp(TRObject) //______________________________________________________________________________ -TRObjectProxy::TRObjectProxy(SEXP xx): TObject(), x(xx) { } +TRObject::TRObject(SEXP xx): TObject(), fObj(xx),fStatus(kTRUE) {Attr.SetObject(xx); } //______________________________________________________________________________ -void TRObjectProxy::operator=(SEXP xx) +void TRObject::operator=(SEXP xx) { - x = xx; + fStatus=kTRUE; + fObj = xx; } //______________________________________________________________________________ -TRObjectProxy::TRObjectProxy(SEXP xx, Bool_t status): x(xx), fStatus(status) { } +TRObject::TRObject(SEXP xx, Bool_t status): fObj(xx), fStatus(status) { Attr.SetObject(xx);} diff --git a/bindings/r/tests/Binding.C b/bindings/r/tests/Binding.C index 6d8564923ffa4..0f0bb773081cb 100644 --- a/bindings/r/tests/Binding.C +++ b/bindings/r/tests/Binding.C @@ -90,7 +90,7 @@ r<<"print(s)"; // r["d"]<()); +// print(head(obj)); +// print(vector); +// x11(); +// plot(sin,0,6,ROOT::R::Label["type"]="s"); // devoff(); - print(vector); +// print(vector); - require("C50"); +// require("C50"); } } diff --git a/bindings/r/tests/Object.C b/bindings/r/tests/Object.C new file mode 100644 index 0000000000000..bc1ddb4c7421d --- /dev/null +++ b/bindings/r/tests/Object.C @@ -0,0 +1,28 @@ +//script to test TRFunction +#include + +ROOT::R::TRInterface &r = ROOT::R::TRInterface::Instance(); + +void Object() +{ +// r.SetVerbose(kFALSE); + ROOT::R::TRFunctionImport print("print"); + + ROOT::R::TRFunctionImport c("c"); + ROOT::R::TRFunctionImport require("require"); + ROOT::R::TRFunctionImport head("head"); + ROOT::R::TRFunctionImport attributes("attributes"); + + ROOT::R::TRObject vector=c(1,2,3,4); + ROOT::R::TRObject v=vector; +// v.SetAttribute("test","test"); + v.Attr["attvector"]=v; + v.Attr["str"]="something"; + r["v"]=v; + + v=v.Attr["str"]; + r["v"]=v; + + print(attributes(v)); + +} diff --git a/math/rtools/src/RMinimizer.cxx b/math/rtools/src/RMinimizer.cxx index 5880ee03931e0..fbc027af7b78a 100644 --- a/math/rtools/src/RMinimizer.cxx +++ b/math/rtools/src/RMinimizer.cxx @@ -1,6 +1,6 @@ #include "TRInterface.h" -#include "TRObjectProxy.h" +#include "TRObject.h" #include "Math/RMinimizer.h" #include "Math/IFunction.h" #include From 87ed90905b9616707d637a20aa5ca05c22317a3b Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sat, 4 Jul 2015 21:59:12 -0500 Subject: [PATCH 08/21] ROOTR: added methods Set/GetAttribute to work with the TRObject Attributes requires error control in the returned TRObject seeting status and in set paasing nullprt --- bindings/r/inc/TRObject.h | 32 ++++++++++---------------------- bindings/r/src/TRObject.cxx | 4 ++-- bindings/r/tests/Object.C | 16 +++++++++------- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/bindings/r/inc/TRObject.h b/bindings/r/inc/TRObject.h index 0599a2db32793..deff77645d406 100644 --- a/bindings/r/inc/TRObject.h +++ b/bindings/r/inc/TRObject.h @@ -30,27 +30,6 @@ namespace ROOT { private: Rcpp::RObject fObj; Bool_t fStatus;//status tell if is a valid object - class Attribute - { - Rcpp::RObject obj; - TString fAttName; - public: - Attribute(){} - void SetObject(Rcpp::RObject o){obj=o;} - - Attribute& operator[](const char* attname) - { - fAttName=attname; - return *this; - } - template RT operator=(T o) - { - obj.attr(fAttName.Data())=o; - return obj; - } - }; - public: - Attribute Attr; public: TRObject(): TObject() {}; TRObject(SEXP xx); @@ -60,7 +39,16 @@ namespace ROOT { Bool_t GetStatus() { return fStatus;} - + template void SetAttribute(const TString name,T obj) + { + fObj.attr(name.Data())=obj; + } + + TRObject GetAttribute(const TString name) + { + return fObj.attr(name.Data()); + } + void operator=(SEXP xx); template TRObject& Wrap(T obj) { diff --git a/bindings/r/src/TRObject.cxx b/bindings/r/src/TRObject.cxx index 4ec56e66182d1..c114059f938c7 100644 --- a/bindings/r/src/TRObject.cxx +++ b/bindings/r/src/TRObject.cxx @@ -36,7 +36,7 @@ using namespace ROOT::R; ClassImp(TRObject) //______________________________________________________________________________ -TRObject::TRObject(SEXP xx): TObject(), fObj(xx),fStatus(kTRUE) {Attr.SetObject(xx); } +TRObject::TRObject(SEXP xx): TObject(), fObj(xx),fStatus(kTRUE) { } //______________________________________________________________________________ @@ -47,4 +47,4 @@ void TRObject::operator=(SEXP xx) } //______________________________________________________________________________ -TRObject::TRObject(SEXP xx, Bool_t status): fObj(xx), fStatus(status) { Attr.SetObject(xx);} +TRObject::TRObject(SEXP xx, Bool_t status): fObj(xx), fStatus(status) {} diff --git a/bindings/r/tests/Object.C b/bindings/r/tests/Object.C index bc1ddb4c7421d..a40c6bac319df 100644 --- a/bindings/r/tests/Object.C +++ b/bindings/r/tests/Object.C @@ -9,20 +9,22 @@ void Object() ROOT::R::TRFunctionImport print("print"); ROOT::R::TRFunctionImport c("c"); + ROOT::R::TRFunctionImport cat("cat"); ROOT::R::TRFunctionImport require("require"); ROOT::R::TRFunctionImport head("head"); ROOT::R::TRFunctionImport attributes("attributes"); ROOT::R::TRObject vector=c(1,2,3,4); ROOT::R::TRObject v=vector; -// v.SetAttribute("test","test"); - v.Attr["attvector"]=v; - v.Attr["str"]="something"; - r["v"]=v; + v.SetAttribute("Size",4); + v.SetAttribute("Name","TestVector"); +// v.SetAttribute("NameNull",NULL); - v=v.Attr["str"]; - r["v"]=v; + int s=v.GetAttribute("Size"); + TString name=v.GetAttribute("Name"); - print(attributes(v)); + print(attributes(v)); + print(cat("ROOT:",s)); + print(cat("ROOT:",name)); } From 0e753a9dd7e085d17c8d9763b16ec0eb508150e6 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sun, 26 Jul 2015 16:46:53 -0500 Subject: [PATCH 09/21] ROOTR: fixed tutorials for TRFunctionExport and TRFunctionExport --- bindings/r/tests/Functions.C | 15 +++++++++++---- tutorials/r/GlobalMinimization.C | 6 ++++-- tutorials/r/Integration.C | 2 +- tutorials/r/Interpolation.C | 3 ++- tutorials/r/Minimization.C | 4 ++-- tutorials/r/TF1.R | 13 ------------- tutorials/r/TFileRead.R | 11 ----------- tutorials/r/TFileWrite.R | 11 ----------- tutorials/r/rootlogon.C | 6 +++--- 9 files changed, 23 insertions(+), 48 deletions(-) delete mode 100644 tutorials/r/TF1.R delete mode 100644 tutorials/r/TFileRead.R delete mode 100644 tutorials/r/TFileWrite.R diff --git a/bindings/r/tests/Functions.C b/bindings/r/tests/Functions.C index ba28e9c554146..190ea8946fa11 100644 --- a/bindings/r/tests/Functions.C +++ b/bindings/r/tests/Functions.C @@ -70,7 +70,7 @@ void Functions(TString type = "Import") ROOT::R::TRFunctionImport c("c"); ROOT::R::TRFunctionImport require("require"); ROOT::R::TRFunctionImport plot("plot"); -// ROOT::R::TRFunctionImport devoff("dev.off"); + ROOT::R::TRFunctionImport devoff("dev.off"); // ROOT::R::TRFunctionImport sin("sin"); // ROOT::R::TRFunctionImport options("options"); @@ -82,7 +82,7 @@ void Functions(TString type = "Import") // options("device='x11'"); // - ROOT::R::TRObjectProxy vector=c(1,2,3,4); + ROOT::R::TRObject vector=c(1,2,3,4); TVectorF v=vector; print(v); // ROOT::R::TRDataFrame obj=read("training.csv"); @@ -90,8 +90,15 @@ void Functions(TString type = "Import") // ROOT::R::TRDataFrame df(obj.As()); // print(head(obj)); // print(vector); -// x11(); -// plot(sin,0,6,ROOT::R::Label["type"]="s"); + x11(); + plot(sin,0,6,ROOT::R::Label["type"]="s"); + x11(); + plot(sin,0,6,ROOT::R::Label["type"]="l"); + x11(); + plot(sin,0,6,ROOT::R::Label["type"]="p"); + + + // devoff(); // print(vector); diff --git a/tutorials/r/GlobalMinimization.C b/tutorials/r/GlobalMinimization.C index e8a21413fe9b4..043bca426c45f 100644 --- a/tutorials/r/GlobalMinimization.C +++ b/tutorials/r/GlobalMinimization.C @@ -51,7 +51,7 @@ void GlobalMinimization() r<<"suppressMessages(library(DEoptim, quietly = TRUE))"; // passing RosenBrock function to R - r["GenRosenBrock"]<IsBatch()) { r<<"dev.new(title='RosenBrock Convergence')"; r<<"plot(result1,type='o',pch='.')"; + r<<"dev.off()"; r<<"dev.new(title='Rastrigin Convergence')"; r<<"plot(result2,type='o',pch='.')"; + r<<"dev.off()"; } } diff --git a/tutorials/r/Integration.C b/tutorials/r/Integration.C index ce7439e2556c3..64cacab37e366 100644 --- a/tutorials/r/Integration.C +++ b/tutorials/r/Integration.C @@ -29,7 +29,7 @@ void Integration() ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - r["BreitWigner"]=ROOT::R::TRFunction(BreitWignerVectorized); + r["BreitWigner"]=ROOT::R::TRFunctionExport(BreitWignerVectorized); Double_t value=r.Eval("integrate(BreitWigner, lower = -2, upper = 2)$value"); diff --git a/tutorials/r/Interpolation.C b/tutorials/r/Interpolation.C index 439282d396627..16d459a2db9fd 100644 --- a/tutorials/r/Interpolation.C +++ b/tutorials/r/Interpolation.C @@ -26,7 +26,7 @@ void Interpolation() // do plotting only in non-batch mode if (!gROOT->IsBatch() ) { - + r<<"dev.new()";//Required to activate new window for plot //Plot parameter. Plotting using two rows and one column r<<"par(mfrow = c(2,1))"; @@ -66,4 +66,5 @@ void Interpolation() r << "print('Result of approxfun with const method')"; r << "print(paste('x = ',x,' f(x) = ',fc(x2)))"; } + r<<"dev.off()";//Required to close new window for plot } diff --git a/tutorials/r/Minimization.C b/tutorials/r/Minimization.C index f8fde75498f0a..7a0bf35aedb0c 100644 --- a/tutorials/r/Minimization.C +++ b/tutorials/r/Minimization.C @@ -32,10 +32,10 @@ void Minimization() ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); //passsing RosenBrock function to R - r["RosenBrock"]=ROOT::R::TRFunction(RosenBrock); + r["RosenBrock"]=ROOT::R::TRFunctionExport(RosenBrock); //passsing RosenBrockGrad function to R - r["RosenBrockGrad"]=ROOT::R::TRFunction(RosenBrockGrad); + r["RosenBrockGrad"]=ROOT::R::TRFunctionExport(RosenBrockGrad); //the option "method" could be "Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN","Brent" //the option "control" lets you put some constraints like diff --git a/tutorials/r/TF1.R b/tutorials/r/TF1.R deleted file mode 100644 index c251e6f3d09e6..0000000000000 --- a/tutorials/r/TF1.R +++ /dev/null @@ -1,13 +0,0 @@ -require(ROOT) -ROOT::LoadModule('Hist') -ROOT::LoadModule('Graf') - -c1 <- new(TCanvas,'c1','dilog',1) -dilog <- new(TF1,'dilog','TMath::DiLog(x)',0,0) -dilog$SetRange(0,2*pi) -dilog$Draw('') #plotting with ROOT's graphics system -c1$Update() - -x<-seq(0,2*pi,by=.1) -gamma<- new(TF1,'gamma','TMath::Gamma(x)',0,2*pi) -plot(x,gamma$Eval(x)) #plotting with R's graphics system diff --git a/tutorials/r/TFileRead.R b/tutorials/r/TFileRead.R deleted file mode 100644 index bfd130189ae70..0000000000000 --- a/tutorials/r/TFileRead.R +++ /dev/null @@ -1,11 +0,0 @@ -require(ROOT) -LoadModule('RIO') -LoadModule('Hist') -LoadModule('Graf') - -rfilein <- new(TFile,'gamma.root','read') -f1 <- rfilein$Get('gamma') -c1<-new(TCanvas,'c1','gamma') -f1$Draw() -c1$Update() -rfilein$Close('') diff --git a/tutorials/r/TFileWrite.R b/tutorials/r/TFileWrite.R deleted file mode 100644 index 95a7c7880938e..0000000000000 --- a/tutorials/r/TFileWrite.R +++ /dev/null @@ -1,11 +0,0 @@ -require(ROOT) -LoadModule('RIO') -LoadModule('Hist') -LoadModule('Graf') - -rfile <- new(TFile,'gamma.root','recreate') -gamma <- new(TF1,'gamma','TMath::Gamma(x)',0.1,2*pi) -gamma$Write('gamma') -rfile$Flush() -rfile$Close() - diff --git a/tutorials/r/rootlogon.C b/tutorials/r/rootlogon.C index 2839d62391c71..fe850d7dd0216 100644 --- a/tutorials/r/rootlogon.C +++ b/tutorials/r/rootlogon.C @@ -1,6 +1,6 @@ -#include +//#include void rootlogon(){ - gSystem->AddIncludePath(RINCLUDEPATH); - gSystem->AddLinkedLibs(RLINKEDLIBS); +// gSystem->AddIncludePath(RINCLUDEPATH); +// gSystem->AddLinkedLibs(RLINKEDLIBS); } From b642a7cf7a2b97c75af21ecc6298bee174dc6682 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sun, 26 Jul 2015 18:58:57 -0500 Subject: [PATCH 10/21] ROOTR: added support for assignation in TRFunctionImport --- bindings/r/inc/TRFunctionImport.h | 1 + bindings/r/src/TRFunctionImport.cxx | 7 +++++++ bindings/r/tests/Functions.C | 13 ++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bindings/r/inc/TRFunctionImport.h b/bindings/r/inc/TRFunctionImport.h index d93110f14f6b6..e37d1bd1fa84e 100644 --- a/bindings/r/inc/TRFunctionImport.h +++ b/bindings/r/inc/TRFunctionImport.h @@ -52,6 +52,7 @@ namespace ROOT { TRFunctionImport(const TString& name); TRFunctionImport(const TString& name, const TString& ns); TRFunctionImport(const TRFunctionImport &fun); + TRFunctionImport(SEXP obj); ~TRFunctionImport(){if(f) delete f;} SEXP operator()(){return (*f)();} diff --git a/bindings/r/src/TRFunctionImport.cxx b/bindings/r/src/TRFunctionImport.cxx index 82dfb24e24c88..3c692baeaa6e6 100644 --- a/bindings/r/src/TRFunctionImport.cxx +++ b/bindings/r/src/TRFunctionImport.cxx @@ -6,6 +6,7 @@ * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #include +#include #ifndef Rcpp_Function_h #include @@ -44,3 +45,9 @@ TRFunctionImport::TRFunctionImport(const TString& name, const TString& ns) { f=new Rcpp::Function(name.Data(),ns.Data()); } + +//______________________________________________________________________________ +TRFunctionImport::TRFunctionImport(SEXP obj) +{ + f=new Rcpp::Function(obj); +} diff --git a/bindings/r/tests/Functions.C b/bindings/r/tests/Functions.C index 190ea8946fa11..343d368d0f63b 100644 --- a/bindings/r/tests/Functions.C +++ b/bindings/r/tests/Functions.C @@ -78,9 +78,20 @@ void Functions(TString type = "Import") ROOT::R::TRFunctionImport read("read.csv"); ROOT::R::TRFunctionImport head("head"); + ROOT::R::TRFunctionImport options("options"); + options(ROOT::R::Label["device"]="x11"); -// options("device='x11'"); + r<<"test <- function() x11"; + ROOT::R::TRFunctionImport test("test"); + + + ROOT::R::TRFunctionImport dev=test(); + +// dev(); + + + options("device='x11'"); // ROOT::R::TRObject vector=c(1,2,3,4); TVectorF v=vector; From d06a2a88ac5b35873bbdada2f11c3585de2e1aa6 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sun, 26 Jul 2015 21:17:45 -0500 Subject: [PATCH 11/21] ROOTR: added example in tutorials for TRFunctionImport --- tutorials/r/Function.C | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tutorials/r/Function.C diff --git a/tutorials/r/Function.C b/tutorials/r/Function.C new file mode 100644 index 0000000000000..c207402501103 --- /dev/null +++ b/tutorials/r/Function.C @@ -0,0 +1,51 @@ +#include + +using namespace ROOT::R; +void Function() +{ + TRInterface &r = TRInterface::Instance(); + r.SetVerbose(1); + //////////////////////////////////////// + //defining functions to be used from R// + //////////////////////////////////////// + TRFunctionImport c("c"); + TRFunctionImport list("list"); + TRFunctionImport asformula("as.formula"); + TRFunctionImport nls("nls"); + TRFunctionImport confint("confint"); + TRFunctionImport summary("summary"); + TRFunctionImport print("print"); + TRFunctionImport plot("plot"); + TRFunctionImport lines("lines"); + TRFunctionImport devnew("dev.new"); + TRFunctionImport devoff("dev.off"); + TRFunctionImport min("min"); + TRFunctionImport max("max"); + TRFunctionImport seq("seq"); + TRFunctionImport predict("predict"); + + r<<"options(device='png')"; + + //////////////////////// + //doing the procedure // + //////////////////////// + TRObject xdata = c(-2,-1.64,-1.33,-0.7,0,0.45,1.2,1.64,2.32,2.9); + TRObject ydata = c(0.699369,0.700462,0.695354,1.03905,1.97389,2.41143,1.91091,0.919576,-0.730975,-1.42001); + + TRDataFrame data; + data["xdata"]=xdata; + data["ydata"]=ydata; + + // fit = nls(ydata ~ p1*cos(p2*xdata) + p2*sin(p1*xdata), start=list(p1=1,p2=0.2)) + TRObject fit = nls(asformula("ydata ~ p1*cos(p2*xdata) + p2*sin(p1*xdata)"),Label["data"]=data, Label["start"]=list(Label["p1"]=1,Label["p2"]=0.2)); + print(summary(fit)); + + print(confint(fit)); + + devnew("Fitting Regression"); + plot(xdata,ydata); + + TRObject xgrid=seq(min(xdata),max(xdata),Label["len"]=10); + lines(xgrid,predict(fit,xgrid),Label["col"] = "green"); + devoff(); +} \ No newline at end of file From 5e7c3ec70f718360eb062a0de4dd149ff29dade1 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Thu, 30 Jul 2015 16:59:07 -0500 Subject: [PATCH 12/21] ROOTR: fixed issue with ROOT::R::Label --- bindings/r/inc/RExports.h | 4 +++ bindings/r/inc/TRDataFrame.h | 1 - bindings/r/inc/TRFunctionImport__oprtr.h | 40 ++++++++++++------------ bindings/r/inc/TRObject.h | 7 +++++ bindings/r/src/RExports.cxx | 3 ++ bindings/r/tests/Functions.C | 6 ++-- bindings/r/tests/training.csv | 4 +++ 7 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 bindings/r/tests/training.csv diff --git a/bindings/r/inc/RExports.h b/bindings/r/inc/RExports.h index 66134a0d93f2e..e6ec3b7c1739f 100644 --- a/bindings/r/inc/RExports.h +++ b/bindings/r/inc/RExports.h @@ -140,6 +140,7 @@ namespace Rcpp { #define R_Version(v,p,s) ((v * 65536) + (p * 256) + (s)) #endif #include//this headers should be called after templates definitions +#include #undef HAVE_UINTPTR_T #include @@ -158,9 +159,12 @@ namespace ROOT { //template function required to create modules using the macro ROOTR_MODULE Rcpp::function(name_, fun, docstring); } + + extern Rcpp::internal::NamedPlaceHolder Label; } } + //macros redifined to be accord with the namespace #define ROOTR_MODULE RCPP_MODULE #define ROOTR_EXPOSED_CLASS RCPP_EXPOSED_CLASS diff --git a/bindings/r/inc/TRDataFrame.h b/bindings/r/inc/TRDataFrame.h index a6d6d4d69f314..9738365815c72 100644 --- a/bindings/r/inc/TRDataFrame.h +++ b/bindings/r/inc/TRDataFrame.h @@ -35,7 +35,6 @@ namespace ROOT { namespace R { -static Rcpp::internal::NamedPlaceHolder Label; class TRDataFrame: public TObject { friend class TRInterface; diff --git a/bindings/r/inc/TRFunctionImport__oprtr.h b/bindings/r/inc/TRFunctionImport__oprtr.h index cc461dbe9794d..a661f9e4c6d78 100644 --- a/bindings/r/inc/TRFunctionImport__oprtr.h +++ b/bindings/r/inc/TRFunctionImport__oprtr.h @@ -11,102 +11,102 @@ #define ROOT_R_TRFunctionImport_oprtr template - SEXP operator()(const T1& t1) const { + TRObject operator()(const T1& t1) const { return (*f)(t1) ; } template - SEXP operator()(const T1& t1, const T2& t2) const { + TRObject operator()(const T1& t1, const T2& t2) const { return (*f)(t1, t2) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3) const { return (*f)(t1, t2, t3) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4) const { return (*f)(t1, t2, t3, t4) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) const { return (*f)(t1, t2, t3, t4, t5) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) const { return (*f)(t1, t2, t3, t4, t5, t6) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) const { return (*f)(t1, t2, t3, t4, t5, t6, t7) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19) ; } template - SEXP operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19, const T20& t20) const { + TRObject operator()(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19, const T20& t20) const { return (*f)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) ; } diff --git a/bindings/r/inc/TRObject.h b/bindings/r/inc/TRObject.h index deff77645d406..e42c5ae81c50a 100644 --- a/bindings/r/inc/TRObject.h +++ b/bindings/r/inc/TRObject.h @@ -71,7 +71,14 @@ namespace ROOT { template T operator=(TRObject &obj) { return ::Rcpp::as(obj); } + operator SEXP() { + return fObj; + } + operator Rcpp::RObject() { + return fObj; + } + template operator T() { if(fStatus) diff --git a/bindings/r/src/RExports.cxx b/bindings/r/src/RExports.cxx index cc39eb24c9ba6..fc1ee4a607387 100644 --- a/bindings/r/src/RExports.cxx +++ b/bindings/r/src/RExports.cxx @@ -10,6 +10,9 @@ #include #include #include + +Rcpp::internal::NamedPlaceHolder ROOT::R::Label; + namespace Rcpp { //TVectorT template<> SEXP wrap(const TVectorT &v) diff --git a/bindings/r/tests/Functions.C b/bindings/r/tests/Functions.C index 343d368d0f63b..9330c8b974e2f 100644 --- a/bindings/r/tests/Functions.C +++ b/bindings/r/tests/Functions.C @@ -95,11 +95,13 @@ void Functions(TString type = "Import") // ROOT::R::TRObject vector=c(1,2,3,4); TVectorF v=vector; + TVectorF v2=c(11,22,33,44); print(v); -// ROOT::R::TRDataFrame obj=read("training.csv"); + print(v2); + ROOT::R::TRDataFrame obj=read("training.csv"); // ROOT::R::TRDataFrame df(obj.As()); -// print(head(obj)); + print(head(obj)); // print(vector); x11(); plot(sin,0,6,ROOT::R::Label["type"]="s"); diff --git a/bindings/r/tests/training.csv b/bindings/r/tests/training.csv new file mode 100644 index 0000000000000..56c2e063b47d2 --- /dev/null +++ b/bindings/r/tests/training.csv @@ -0,0 +1,4 @@ +var1,var2,class +1.01,2.3, s +0.01,0.1, b + From 770095a6e4702e6ca3f6eac442d5b3cd87bfbf38 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sat, 1 Aug 2015 18:21:08 -0500 Subject: [PATCH 13/21] ROOTR: documented TRObject with Doxygen --- bindings/r/inc/TRObject.h | 72 ++++++++++++++++++++++++++++++++++--- bindings/r/src/TRObject.cxx | 33 +++-------------- tutorials/r/Function.C | 2 +- 3 files changed, 73 insertions(+), 34 deletions(-) diff --git a/bindings/r/inc/TRObject.h b/bindings/r/inc/TRObject.h index e42c5ae81c50a..66b9cb4085682 100644 --- a/bindings/r/inc/TRObject.h +++ b/bindings/r/inc/TRObject.h @@ -17,9 +17,29 @@ //________________________________________________________________________________________________________ /** - This is a class to get ROOT's objects from R's objects +This is a class to get ROOT's objects from R's objects +

TRObject class

+

+The TRObject class lets you obtain ROOT's objects from R's objects.
+It has some basic template opetarors to convert R's objects into ROOT's datatypes
+

+A simple example
+

+

+
+\code{.cpp} +#include +void Proxy() +{ +ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); +ROOT::R::TRObject obj; +obj=r.Eval("seq(1,10)"); +TVectorD v=obj; +v.Print(); +} +\endcode @ingroup R */ @@ -28,22 +48,54 @@ namespace ROOT { class TRObject: public TObject { friend SEXP Rcpp::wrap(const TRObject &f); private: - Rcpp::RObject fObj; + Rcpp::RObject fObj; //insternal Rcpp::RObject Bool_t fStatus;//status tell if is a valid object public: + /** + Construct and TRObject + */ TRObject(): TObject() {}; - TRObject(SEXP xx); - TRObject(SEXP xx, Bool_t status); + /** + Construct and TRObject given a R base object + \@param robj raw R object + */ + TRObject(SEXP robj); + /** + Construct and TRObject given a R base object + \@param robj raw R object + \@param status if the raw object is valid obj + */ + TRObject(SEXP robj, Bool_t status); + /** + TRObject is a current valid object? + \@param status if the current object is valid obj + */ void SetStatus(Bool_t status){ fStatus = status;} + /** + TRObject is a current valid object? + \@return status if the current object + */ Bool_t GetStatus() { return fStatus;} + /** + The R objects can to have associate attributes + with this method you can added attribute to TRObject given an object in the template argument. + \@param name attribute name + \@param obj object associated to the attribute name in the current TRObject + */ template void SetAttribute(const TString name,T obj) { fObj.attr(name.Data())=obj; } + /** + The R objects can to have associate attributes + with this method you can added attribute to TRObject given an object in the template argument. + \@param name attribute name + \@return object associated to the attribute name in the current TRObject + */ TRObject GetAttribute(const TString name) { return fObj.attr(name.Data()); @@ -51,11 +103,23 @@ namespace ROOT { void operator=(SEXP xx); + /** + Some datatypes of ROOT or c++ can be wrapped in to a TRObject, + this method lets you wrap those datatypes + \@param obj template object to be wrapped + \@return TRObject reference of wrapped object + */ template TRObject& Wrap(T obj) { fObj=::Rcpp::wrap(obj); return *this; } + /** + Some datatypes of ROOT or c++ can be wrapped in to a TRObject, + this method lets you unwrap those datatypes encapsulate into this TRObject. + \note If the current TRObject is not a valid object it will return and empty object and print and error message + \@return template return with the require datatype + */ template T As() { if(fStatus) { diff --git a/bindings/r/src/TRObject.cxx b/bindings/r/src/TRObject.cxx index 125ab92704825..1f29cedbc281c 100644 --- a/bindings/r/src/TRObject.cxx +++ b/bindings/r/src/TRObject.cxx @@ -7,45 +7,20 @@ *************************************************************************/ #include #include -//////////////////////////////////////////////////////////////////////////////// - -/* Begin_Html -

TRObject class

- -

-The TRObject class lets you obtain ROOT's objects from R's objects.
-It has some basic template opetarors to convert R's objects into ROOT's datatypes
-

-A simple example
-

- -

-
-End_Html -#include -void Proxy() -{ -ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -ROOT::R::TRObject obj; -obj=r.ParseEval("seq(1,10)"); -TVectorD v=obj; -v.Print(); -} -*/ using namespace ROOT::R; ClassImp(TRObject) //______________________________________________________________________________ -TRObject::TRObject(SEXP xx): TObject(), fObj(xx),fStatus(kTRUE) { } +TRObject::TRObject(SEXP robj): TObject(), fObj(robj),fStatus(kTRUE) { } //______________________________________________________________________________ -void TRObject::operator=(SEXP xx) +void TRObject::operator=(SEXP robj) { fStatus=kTRUE; - fObj = xx; + fObj = robj; } //______________________________________________________________________________ -TRObject::TRObject(SEXP xx, Bool_t status): fObj(xx), fStatus(status) {} +TRObject::TRObject(SEXP robj, Bool_t status): fObj(robj), fStatus(status) {} diff --git a/tutorials/r/Function.C b/tutorials/r/Function.C index c207402501103..7fc0f1755b47f 100644 --- a/tutorials/r/Function.C +++ b/tutorials/r/Function.C @@ -48,4 +48,4 @@ void Function() TRObject xgrid=seq(min(xdata),max(xdata),Label["len"]=10); lines(xgrid,predict(fit,xgrid),Label["col"] = "green"); devoff(); -} \ No newline at end of file +} From 3e95e322e276b510770259b2c0156addda52f566 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sun, 2 Aug 2015 05:03:45 -0500 Subject: [PATCH 14/21] ROOTR: added documentation for TRDataFrame with doxygen --- bindings/r/inc/TRDataFrame.h | 215 ++++++++++++++++++++++++++++++++- bindings/r/inc/TRObject.h | 35 +++--- bindings/r/src/TRDataFrame.cxx | 198 ------------------------------ 3 files changed, 228 insertions(+), 220 deletions(-) diff --git a/bindings/r/inc/TRDataFrame.h b/bindings/r/inc/TRDataFrame.h index 9738365815c72..0a7724fdffa90 100644 --- a/bindings/r/inc/TRDataFrame.h +++ b/bindings/r/inc/TRDataFrame.h @@ -26,8 +26,149 @@ //________________________________________________________________________________________________________ /** - This is a base class to create DataFrames from ROOT to R +This is a base class to create DataFrames from ROOT to R +

TRDataFrame class

+ +DataFrame is a very important datatype in R and in ROOTR we have a class to manipulate
+dataframes called TRDataFrame, with a lot of very useful operators overloaded to work with TRDataFrame's objects
+in a similar way that in the R environment but from c++ in ROOT.
+Example:
+
+Lets to create need data to play with dataframe features
+ +

Creating variables


+\code{.cpp} +TVectorD v1(3); +std::vector v2(3); +std::array v3{ {1,2,3} }; +std::list names; +\endcode + +

Assigning values


+\code{.cpp} +v1[0]=1; +v1[1]=2; +v1[2]=3; + +v2[0]=0.101; +v2[1]=0.202; +v2[2]=0.303; + +names.push_back("v1"); +names.push_back("v2"); +names.push_back("v3"); + +ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); +\endcode + +In R the dataframe have associate to every column a label, +in ROOTR you can have the same label using the class ROOT::R::Label to create a TRDataFrame where you data +have a label associate. +

Creating dataframe object with its labels


+\code{.cpp} +using namespace ROOT::R; +TRDataFrame df1(Label["var1"]=v1,Label["var2"]=v2,Label["var3"]=v3,Label["strings"]=names); +\endcode + +

Passing dataframe to R's environment


+\code{.cpp} +r["df1"]<Adding colunms to dataframe
+\code{.cpp} +TVectorD v4(3); +//filling the vector fro R's environment +r["c(-1,-2,-3)"]>>v4; +//adding new colunm to df1 with name var4 +df1["var4"]=v4; +//updating df1 in R's environment +r["df1"]<Getting dataframe from R's environment
+\code{.cpp} +ROOT::R::TRDataFrame df2; + +r<<"df2<-data.frame(v1=c(0.1,0.2,0.3),v2=c(3,2,1))"; +r["df2"]>>df2; + +TVectorD v(3); +df2["v1"]>>v; +v.Print(); + +df2["v2"]>>v; +v.Print(); +\endcode + +Output +\code +Vector (3) is as follows + + | 1 | +------------------ + 0 |0.1 + 1 |0.2 + 2 |0.3 + +Vector (3) is as follows + + | 1 | +------------------ + 0 |3 + 1 |2 + 2 |1 +\endcode + +Working with colunms between dataframes
+\code{.cpp} +df2["v3"]<Working with colunms between dataframes
+\code{.cpp} +//passing values from colunm v3 of df2 to var1 of df1 +df2["v3"]>>df1["var1"]; +//updating df1 in R's environment +r["df1"]<(const TRDataFrame &f); protected: - Rcpp::DataFrame df; + Rcpp::DataFrame df; //internal Rcpp::DataFrame public: //Proxy class to use operators for assignation Ex: df["name"]>>object class Binding { friend class TRDataFrame; public: + /** + Construct a Binding nestead class for facilities with operators + \param _df Rcpp::DataFrame (internal from TDataFrame) + \param name string to use in assignations + */ Binding(Rcpp::DataFrame &_df,TString name):fName(name),fDf(_df) {} + /** + Copy constructor for Binding nestead class + \param obj object with Rcpp::DataFame objecta and string with name + */ Binding(const Binding &obj):fName(obj.fName),fDf(obj.fDf){} + /** + template method for operator assignation + \param var any R wrappable datatype + */ template Binding operator=(T var) { int size = fDf.size(),i=0 ; Rcpp::CharacterVector names=fDf.attr("names"); @@ -85,6 +239,10 @@ class TRDataFrame: public TObject { } return *this; } + /** + method for operator assignation of Binding class + \param obj other Binding object + */ Binding operator=(Binding obj) { int size = fDf.size(),i=0 ; @@ -120,6 +278,11 @@ class TRDataFrame: public TObject { return *this; } + /** + Template method for operator >> that lets to use dataframes like streams + example: df["v"]>>vector; + \param var any datatype that can be assigned from dataframe label + */ template Binding &operator >>(T &var) { var = Rcpp::as(fDf[fName.Data()]); return *this; @@ -129,6 +292,11 @@ class TRDataFrame: public TObject { return var; } + /** + Template method for operator << that lets to use dataframes like streams + example: df["v"]< Binding &operator <<(T var) { int size = fDf.size(),i=0 ; Rcpp::CharacterVector names=fDf.attr("names"); @@ -169,16 +337,32 @@ class TRDataFrame: public TObject { } private: - TString fName; - Rcpp::DataFrame &fDf; + TString fName; //name of label + Rcpp::DataFrame &fDf;//internal dataframe }; + /** + Default TDataFrame contructor + */ TRDataFrame(); + /** + TDataFrame contructor + \param obj raw R object that can be casted to DataFrame + */ TRDataFrame(SEXP obj){df=Rcpp::as(obj);} + /** + TDataFrame copy contructor + \param _df other TRDataFrame + */ TRDataFrame(const TRDataFrame &_df); + /** + TDataFrame contructor for Rcpp::DataFrame + \param _df raw dataframe from Rcpp + */ TRDataFrame(const Rcpp::DataFrame &_df):df(_df){}; -#include + #include + Binding operator[](const TString &name); TRDataFrame& operator=(TRDataFrame &obj) { @@ -194,8 +378,20 @@ class TRDataFrame: public TObject { return *this; } + /** + Method to get the number of colunms + \return number of cols + */ int GetNcols(){return df.size();} + /** + Method to get the number of rows + \return number of rows + */ int GetNrows(){return df.nrows();} + /** + Method to get labels of dataframe + \return colunms names + */ TVectorString GetColNames() { Rcpp::CharacterVector names=df.attr("names"); @@ -204,12 +400,21 @@ class TRDataFrame: public TObject { return rnames; } + /** + Method to get dataframe as matrix + \note only work on numerical dataframes if some column if string or other it will fail + \return TMatrixT with a given tamplate data type + */ template TMatrixT AsMatrix() { TRFunctionImport asMatrix("as.matrix"); return Rcpp::as >(asMatrix(df)); } + /** + Method to print the dataframe in stdout or a column given the label + \param label nomber of the column to print + */ void Print(TString label="") { TRFunctionImport print("print"); diff --git a/bindings/r/inc/TRObject.h b/bindings/r/inc/TRObject.h index 66b9cb4085682..76011f792587c 100644 --- a/bindings/r/inc/TRObject.h +++ b/bindings/r/inc/TRObject.h @@ -17,6 +17,7 @@ //________________________________________________________________________________________________________ /** + This is a class to get ROOT's objects from R's objects

TRObject class

@@ -28,7 +29,7 @@ A simple example

-
+ \code{.cpp} #include void Proxy() @@ -52,38 +53,38 @@ namespace ROOT { Bool_t fStatus;//status tell if is a valid object public: /** - Construct and TRObject + Construct a TRObject */ TRObject(): TObject() {}; /** - Construct and TRObject given a R base object - \@param robj raw R object + Construct a TRObject given a R base object + \param robj raw R object */ TRObject(SEXP robj); /** - Construct and TRObject given a R base object - \@param robj raw R object - \@param status if the raw object is valid obj + Construct a TRObject given a R base object + \param robj raw R object + \param status if the raw object is valid obj */ TRObject(SEXP robj, Bool_t status); /** TRObject is a current valid object? - \@param status if the current object is valid obj + \param status if the current object is valid obj */ void SetStatus(Bool_t status){ fStatus = status;} /** TRObject is a current valid object? - \@return status if the current object + \return status if the current object */ Bool_t GetStatus() { return fStatus;} /** The R objects can to have associate attributes with this method you can added attribute to TRObject given an object in the template argument. - \@param name attribute name - \@param obj object associated to the attribute name in the current TRObject + \param name attribute name + \param obj object associated to the attribute name in the current TRObject */ template void SetAttribute(const TString name,T obj) { @@ -93,8 +94,8 @@ namespace ROOT { /** The R objects can to have associate attributes with this method you can added attribute to TRObject given an object in the template argument. - \@param name attribute name - \@return object associated to the attribute name in the current TRObject + \param name attribute name + \return object associated to the attribute name in the current TRObject */ TRObject GetAttribute(const TString name) { @@ -106,8 +107,8 @@ namespace ROOT { /** Some datatypes of ROOT or c++ can be wrapped in to a TRObject, this method lets you wrap those datatypes - \@param obj template object to be wrapped - \@return TRObject reference of wrapped object + \param obj template object to be wrapped + \return TRObject reference of wrapped object */ template TRObject& Wrap(T obj) { fObj=::Rcpp::wrap(obj); @@ -117,8 +118,8 @@ namespace ROOT { /** Some datatypes of ROOT or c++ can be wrapped in to a TRObject, this method lets you unwrap those datatypes encapsulate into this TRObject. - \note If the current TRObject is not a valid object it will return and empty object and print and error message - \@return template return with the require datatype + \note If the current TRObject is not a valid object it will return and empty object and it will print an error message + \return template return with the require datatype */ template T As() { if(fStatus) diff --git a/bindings/r/src/TRDataFrame.cxx b/bindings/r/src/TRDataFrame.cxx index 02486ab048bcf..04dfa9bf50bdd 100644 --- a/bindings/r/src/TRDataFrame.cxx +++ b/bindings/r/src/TRDataFrame.cxx @@ -8,204 +8,6 @@ #include //////////////////////////////////////////////////////////////////////////////// -/* Begin_Html -

TRDataFrame class

- -DataFrame? is a very important datatype in R and in ROOTR we have a class to manipulate
-dataframes called TRDataFrame, with a lot of very useful operators overloaded to work with TRDataFrame's objects
-in a similar way that in the R environment but from c++ in ROOT.
-Example:
-
-Lets to create need data to play with dataframe features
-End_Html - -Begin_Html -
-///////////////////////////////////
-//creating variables///
-//////////////////////////////////
-End_Html -TVectorD v1(3); -std::vector v2(3); -std::array v3{ {1,2,3} }; -std::list names; - -Begin_Html -//////////////////////////////////
-//assigning values//
-//////////////////////////////////
-End_Html -v1[0]=1; -v1[1]=2; -v1[2]=3; - -v2[0]=0.101; -v2[1]=0.202; -v2[2]=0.303; - -names.push_back("v1"); -names.push_back("v2"); -names.push_back("v3"); - -ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -Begin_Html -
-End_Html - -Begin_Html -In R the dataframe have associate to every column a label, -in ROOTR you can have the same label using the class ROOT::R::Label to create a TRDataFrame where you data -have a label associate. -End_Html - -Begin_Html -
-///////////////////////////////////////////////////////////////////
-//creating dataframe object with its labels//
-///////////////////////////////////////////////////////////////////
-End_Html -using namespace ROOT::R; -TRDataFrame df1(Label["var1"]=v1,Label["var2"]=v2,Label["var3"]=v3,Label["strings"]=names); -Begin_Html -//////////////////////////////////////////////////////////////////
-//Passing dataframe to R's environment//
-/////////////////////////////////////////////////////////////////
-End_Html -r["df1"]< -End_Html - - -Output -var1 var2 var3 strings -1 1 0.101 1 v1 -2 2 0.202 2 v2 -3 3 0.303 3 v3 - - -Begin_Html -Manipulating data between dataframes -End_Html - -Begin_Html -
-/////////////////////////////////////////////////////
-//Adding colunms to dataframe //
-/////////////////////////////////////////////////////
-End_Html - -TVectorD v4(3); -//filling the vector fro R's environment -r["c(-1,-2,-3)"]>>v4; -//adding new colunm to df1 with name var4 -df1["var4"]=v4; -//updating df1 in R's environment -r["df1"]< -End_Html - - -Output -var1 var2 var3 strings var4 -1 1 0.101 1 v1 -1 -2 2 0.202 2 v2 -2 -3 3 0.303 3 v3 -3 - - -Getting data frames from R's environment - -Begin_Html -
-/////////////////////////////////////////////////////////////////////
-//Getting dataframe from R's environment//
-/////////////////////////////////////////////////////////////////////
-End_Html -ROOT::R::TRDataFrame df2; - -r<<"df2<-data.frame(v1=c(0.1,0.2,0.3),v2=c(3,2,1))"; -r["df2"]>>df2; - -TVectorD v(3); -df2["v1"]>>v; -v.Print(); - -df2["v2"]>>v; -v.Print(); -Begin_Html -
-End_Html - -Output -Vector (3) is as follows - - | 1 | ------------------- - 0 |0.1 - 1 |0.2 - 2 |0.3 - -Vector (3) is as follows - - | 1 | ------------------- - 0 |3 - 1 |2 - 2 |1 - - -Begin_Html -
-/////////////////////////////////////////////////////////////////////////
-//Working with colunms between dataframes//
-/////////////////////////////////////////////////////////////////////////
-End_Html - -df2["v3"]< -End_Html - - -Output -v1 v2 v3 -1 0.1 3 v1 -2 0.2 2 v2 -3 0.3 1 v3 - - -Begin_Html -
-//////////////////////////////////////////////////////////////////////
-//Working with colunms between dataframes//
-//////////////////////////////////////////////////////////////////////
-End_Html - -//passing values from colunm v3 of df2 to var1 of df1 -df2["v3"]>>df1["var1"]; -//updating df1 in R's environment -r["df1"]< -End_Html - - -Output -var1 var2 var3 strings var4 -1 v1 0.101 1 v1 -1 -2 v2 0.202 2 v2 -2 -3 v3 0.303 3 v3 -3 -*/ - using namespace ROOT::R; ClassImp(TRDataFrame) From 28484e59915cc91738dc1c5a092441637e9bf5f7 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sun, 2 Aug 2015 20:15:53 -0500 Subject: [PATCH 15/21] ROOTR: working to improved ROOTR documentation with doxygen --- bindings/r/inc/TRDataFrame.h | 767 ++++++++++++++-------------- bindings/r/inc/TRFunctionExport.h | 151 +++++- bindings/r/inc/TRFunctionImport.h | 150 +++++- bindings/r/inc/TRInterface.h | 27 +- bindings/r/inc/TRObject.h | 266 +++++----- bindings/r/src/TRDataFrame.cxx | 10 +- bindings/r/src/TRFunctionExport.cxx | 105 ---- bindings/r/src/TRFunctionImport.cxx | 5 - 8 files changed, 824 insertions(+), 657 deletions(-) diff --git a/bindings/r/inc/TRDataFrame.h b/bindings/r/inc/TRDataFrame.h index 0a7724fdffa90..373880c756104 100644 --- a/bindings/r/inc/TRDataFrame.h +++ b/bindings/r/inc/TRDataFrame.h @@ -24,406 +24,415 @@ #include #endif -//________________________________________________________________________________________________________ -/** - -This is a base class to create DataFrames from ROOT to R -

TRDataFrame class

- -DataFrame is a very important datatype in R and in ROOTR we have a class to manipulate
-dataframes called TRDataFrame, with a lot of very useful operators overloaded to work with TRDataFrame's objects
-in a similar way that in the R environment but from c++ in ROOT.
-Example:
-
-Lets to create need data to play with dataframe features
- -

Creating variables


-\code{.cpp} -TVectorD v1(3); -std::vector v2(3); -std::array v3{ {1,2,3} }; -std::list names; -\endcode - -

Assigning values


-\code{.cpp} -v1[0]=1; -v1[1]=2; -v1[2]=3; - -v2[0]=0.101; -v2[1]=0.202; -v2[2]=0.303; - -names.push_back("v1"); -names.push_back("v2"); -names.push_back("v3"); - -ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -\endcode - -In R the dataframe have associate to every column a label, -in ROOTR you can have the same label using the class ROOT::R::Label to create a TRDataFrame where you data -have a label associate. -

Creating dataframe object with its labels


-\code{.cpp} -using namespace ROOT::R; -TRDataFrame df1(Label["var1"]=v1,Label["var2"]=v2,Label["var3"]=v3,Label["strings"]=names); -\endcode - -

Passing dataframe to R's environment


-\code{.cpp} -r["df1"]<Adding colunms to dataframe
-\code{.cpp} -TVectorD v4(3); -//filling the vector fro R's environment -r["c(-1,-2,-3)"]>>v4; -//adding new colunm to df1 with name var4 -df1["var4"]=v4; -//updating df1 in R's environment -r["df1"]<Getting dataframe from R's environment
-\code{.cpp} -ROOT::R::TRDataFrame df2; - -r<<"df2<-data.frame(v1=c(0.1,0.2,0.3),v2=c(3,2,1))"; -r["df2"]>>df2; - -TVectorD v(3); -df2["v1"]>>v; -v.Print(); - -df2["v2"]>>v; -v.Print(); -\endcode - -Output -\code -Vector (3) is as follows - - | 1 | ------------------- - 0 |0.1 - 1 |0.2 - 2 |0.3 - -Vector (3) is as follows - - | 1 | ------------------- - 0 |3 - 1 |2 - 2 |1 -\endcode - -Working with colunms between dataframes
-\code{.cpp} -df2["v3"]<Working with colunms between dataframes
-\code{.cpp} -//passing values from colunm v3 of df2 to var1 of df1 -df2["v3"]>>df1["var1"]; -//updating df1 in R's environment -r["df1"]<(const TRDataFrame &f); -protected: - Rcpp::DataFrame df; //internal Rcpp::DataFrame -public: - //Proxy class to use operators for assignation Ex: df["name"]>>object - class Binding { - friend class TRDataFrame; - public: - /** - Construct a Binding nestead class for facilities with operators - \param _df Rcpp::DataFrame (internal from TDataFrame) - \param name string to use in assignations - */ - Binding(Rcpp::DataFrame &_df,TString name):fName(name),fDf(_df) {} - /** - Copy constructor for Binding nestead class - \param obj object with Rcpp::DataFame objecta and string with name - */ - Binding(const Binding &obj):fName(obj.fName),fDf(obj.fDf){} - /** - template method for operator assignation - \param var any R wrappable datatype - */ - template Binding operator=(T var) { - int size = fDf.size(),i=0 ; - Rcpp::CharacterVector names=fDf.attr("names"); - bool found=false; - while(i

TRDataFrame class

+ + DataFrame is a very important datatype in R and in ROOTR we have a class to manipulate
+ dataframes called TRDataFrame, with a lot of very useful operators overloaded to work with TRDataFrame's objects
+ in a similar way that in the R environment but from c++ in ROOT.
+ Example:
+
+ Lets to create need data to play with dataframe features
+ +

Creating variables


+ \code{.cpp} + TVectorD v1(3); + std::vector v2(3); + std::array v3{ {1,2,3} }; + std::list names; + \endcode + +

Assigning values


+ \code{.cpp} + v1[0]=1; + v1[1]=2; + v1[2]=3; + + v2[0]=0.101; + v2[1]=0.202; + v2[2]=0.303; + + names.push_back("v1"); + names.push_back("v2"); + names.push_back("v3"); + + ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); + \endcode + + In R the dataframe have associate to every column a label, + in ROOTR you can have the same label using the class ROOT::R::Label to create a TRDataFrame where you data + have a label associate. +

Creating dataframe object with its labels


+ \code{.cpp} + using namespace ROOT::R; + TRDataFrame df1(Label["var1"]=v1,Label["var2"]=v2,Label["var3"]=v3,Label["strings"]=names); + \endcode + +

Passing dataframe to R's environment


+ \code{.cpp} + r["df1"]<Adding colunms to dataframe
+ \code{.cpp} + TVectorD v4(3); + //filling the vector fro R's environment + r["c(-1,-2,-3)"]>>v4; + //adding new colunm to df1 with name var4 + df1["var4"]=v4; + //updating df1 in R's environment + r["df1"]<Getting dataframe from R's environment
+ \code{.cpp} + ROOT::R::TRDataFrame df2; + + r<<"df2<-data.frame(v1=c(0.1,0.2,0.3),v2=c(3,2,1))"; + r["df2"]>>df2; + + TVectorD v(3); + df2["v1"]>>v; + v.Print(); + + df2["v2"]>>v; + v.Print(); + \endcode + + Output + \code + Vector (3) is as follows + + | 1 | + ------------------ + 0 |0.1 + 1 |0.2 + 2 |0.3 + + Vector (3) is as follows + + | 1 | + ------------------ + 0 |3 + 1 |2 + 2 |1 + \endcode + + Working with colunms between dataframes
+ \code{.cpp} + df2["v3"]<Working with colunms between dataframes
+ \code{.cpp} + //passing values from colunm v3 of df2 to var1 of df1 + df2["v3"]>>df1["var1"]; + //updating df1 in R's environment + r["df1"]<Users Guide + http://oproject.org/tiki-index.php?page=ROOT+R+Users+Guide
+ https://root.cern.ch/drupal/content/how-use-r-root-root-r-interface + @ingroup R + */ + + + class TRDataFrame: public TObject { + friend class TRInterface; + friend SEXP Rcpp::wrap(const TRDataFrame &f); + protected: + Rcpp::DataFrame df; //internal Rcpp::DataFrame + public: + //Proxy class to use operators for assignation Ex: df["name"]>>object + class Binding { + friend class TRDataFrame; + public: + /** + Construct a Binding nestead class for facilities with operators + \param _df Rcpp::DataFrame (internal from TDataFrame) + \param name string to use in assignations + */ + Binding(Rcpp::DataFrame &_df, TString name): fName(name), fDf(_df) {} + /** + Copy constructor for Binding nestead class + \param obj object with Rcpp::DataFame objecta and string with name + */ + Binding(const Binding &obj): fName(obj.fName), fDf(obj.fDf) {} + /** + template method for operator assignation + \param var any R wrappable datatype + */ + template Binding operator=(T var) { - if(size==0) - { - fDf=Rcpp::DataFrame::create(ROOT::R::Label[fName.Data()]=var); - }else - { - Rcpp::List nDf(size+1); - Rcpp::CharacterVector nnames(size+1); - for(i=0; i> that lets to use dataframes like streams + example: df["v"]>>vector; + \param var any datatype that can be assigned from dataframe label + */ + template Binding &operator >>(T &var) { - Rcpp::List nDf(size+1); - Rcpp::CharacterVector nnames(size+1); - for(i=0; i(fDf[fName.Data()]); + return *this; } - - return *this; - } - - /** - Template method for operator >> that lets to use dataframes like streams - example: df["v"]>>vector; - \param var any datatype that can be assigned from dataframe label - */ - template Binding &operator >>(T &var) { - var = Rcpp::as(fDf[fName.Data()]); - return *this; - } - Binding operator >>(Binding var) { - var.fDf[var.fName.Data()] = fDf[fName.Data()]; - return var; - } - - /** - Template method for operator << that lets to use dataframes like streams - example: df["v"]< Binding &operator <<(T var) { - int size = fDf.size(),i=0 ; - Rcpp::CharacterVector names=fDf.attr("names"); - bool found=false; - while(i>(Binding var) { - if(names[i]==fName.Data()) - { - found=true; - break; - } - i++; + var.fDf[var.fName.Data()] = fDf[fName.Data()]; + return var; } - if(found) fDf[fName.Data()]=var; - else + + /** + Template method for operator << that lets to use dataframes like streams + example: df["v"]< Binding &operator <<(T var) { - Rcpp::List nDf(size+1); - Rcpp::CharacterVector nnames(size+1); - for(i=0; i operator T() { - return Rcpp::as(fDf[fName.Data()]); - } - template operator T() const{ - return Rcpp::as(fDf[fName.Data()]); - } - - private: - TString fName; //name of label - Rcpp::DataFrame &fDf;//internal dataframe - }; - - /** - Default TDataFrame contructor - */ - TRDataFrame(); - /** - TDataFrame contructor - \param obj raw R object that can be casted to DataFrame - */ - TRDataFrame(SEXP obj){df=Rcpp::as(obj);} - /** - TDataFrame copy contructor - \param _df other TRDataFrame - */ - TRDataFrame(const TRDataFrame &_df); - /** - TDataFrame contructor for Rcpp::DataFrame - \param _df raw dataframe from Rcpp - */ - TRDataFrame(const Rcpp::DataFrame &_df):df(_df){}; - - #include - - Binding operator[](const TString &name); - - TRDataFrame& operator=(TRDataFrame &obj) { - df=obj.df; + template operator T() + { + return Rcpp::as(fDf[fName.Data()]); + } + template operator T() const + { + return Rcpp::as(fDf[fName.Data()]); + } + + private: + TString fName; //name of label + Rcpp::DataFrame &fDf;//internal dataframe + }; + + /** + Default TDataFrame constructor + */ + TRDataFrame(); + /** + TDataFrame constructor + \param obj raw R object that can be casted to DataFrame + */ + TRDataFrame(SEXP obj) + { + df = Rcpp::as(obj); + } + /** + TDataFrame copy constructor + \param _df other TRDataFrame + */ + TRDataFrame(const TRDataFrame &_df); + /** + TDataFrame constructor for Rcpp::DataFrame + \param _df raw dataframe from Rcpp + */ + TRDataFrame(const Rcpp::DataFrame &_df): df(_df) {}; + +#include + + Binding operator[](const TString &name); + + TRDataFrame &operator=(TRDataFrame &obj) + { + df = obj.df; return *this; } - TRDataFrame& operator=(TRDataFrame obj) { - df=obj.df; + TRDataFrame &operator=(TRDataFrame obj) + { + df = obj.df; return *this; } - TRDataFrame& operator=(SEXP obj) { - df=Rcpp::as(obj); + TRDataFrame &operator=(SEXP obj) + { + df = Rcpp::as(obj); return *this; - } - - /** - Method to get the number of colunms - \return number of cols - */ - int GetNcols(){return df.size();} - /** - Method to get the number of rows - \return number of rows - */ - int GetNrows(){return df.nrows();} - /** - Method to get labels of dataframe - \return colunms names - */ - TVectorString GetColNames() - { - Rcpp::CharacterVector names=df.attr("names"); + } + + /** + Method to get the number of colunms + \return number of cols + */ + int GetNcols() + { + return df.size(); + } + /** + Method to get the number of rows + \return number of rows + */ + int GetNrows() + { + return df.nrows(); + } + /** + Method to get labels of dataframe + \return colunms names + */ + TVectorString GetColNames() + { + Rcpp::CharacterVector names = df.attr("names"); TVectorString rnames(GetNcols()); - for(int i=0;i TMatrixT AsMatrix() - { - TRFunctionImport asMatrix("as.matrix"); - return Rcpp::as >(asMatrix(df)); - } - - /** - Method to print the dataframe in stdout or a column given the label - \param label nomber of the column to print - */ - void Print(TString label="") - { - TRFunctionImport print("print"); - if(label=="") print(df); - else print(df[label.Data()]); - } - ClassDef(TRDataFrame, 0) // -}; -} + } + + /** + Method to get dataframe as matrix + \note only work on numerical dataframes if some column if string or other it will fail + \return TMatrixT with a given tamplate data type + */ + template TMatrixT AsMatrix() + { + TRFunctionImport asMatrix("as.matrix"); + return Rcpp::as >(asMatrix(df)); + } + + /** + Method to print the dataframe in stdout or a column given the label + \param label nomber of the column to print + */ + void Print(TString label = "") + { + TRFunctionImport print("print"); + if (label == "") print(df); + else print(df[label.Data()]); + } + ClassDef(TRDataFrame, 0) // + }; + } } diff --git a/bindings/r/inc/TRFunctionExport.h b/bindings/r/inc/TRFunctionExport.h index f4a08499e252f..5875fc61bb5e7 100644 --- a/bindings/r/inc/TRFunctionExport.h +++ b/bindings/r/inc/TRFunctionExport.h @@ -16,36 +16,161 @@ #include #endif -//________________________________________________________________________________________________________ -/** - This is a base class to pass functions from ROOT to R - - - @ingroup R -*/ namespace ROOT { namespace R { + /** + This is a class to pass functions from ROOT to R +

TRFunctionExport class

+

+ The TRFunctionExport class lets you pass ROOT's functions to R's environment
+

+

+ The next example was based in
+ + http://root.cern.ch/root/html/tutorials/fit/NumericalMinimization.C.html +
+ + http://stat.ethz.ch/R-manual/R-devel/library/stats/html/optim.html
+ +

+ + Let \f$ f(x,y)=(x-1)^{2} + 100(y-x^{2})^{2} \f$, which is called the Rosenbrock + function. + + It's known that this function has a minimum when \f$ y = x^{2}\f$ , and \f$ x = 1.\f$ + Let's get the minimum using R's optim package through ROOTR's interface. + In the code this function was called "Double_t RosenBrock(const TVectorD xx )", because for + optim, the input in your function definition must be a single vector. + + The Gradient is formed by + + \f$ \frac{\partial f}{\partial x} = -400x(y - x^{2}) - 2(1 - x) \f$ + + \f$ \frac{\partial f}{\partial y} = 200(y - x^{2}); \f$ + + The "TVectorD RosenBrockGrad(const TVectorD xx )" function + must have a single vector as the argument a it will return a single vetor. + + \code{.cpp} + #include + + //in the next function the pointer *double must be changed by TVectorD, because the pointer has no + //sense in R's environment. + Double_t RosenBrock(const TVectorD xx ) + { + const Double_t x = xx[0]; + const Double_t y = xx[1]; + const Double_t tmp1 = y-x*x; + const Double_t tmp2 = 1-x; + return 100*tmp1*tmp1+tmp2*tmp2; + } + + TVectorD RosenBrockGrad(const TVectorD xx ) + { + const Double_t x = xx[0]; + const Double_t y = xx[1]; + TVectorD grad(2); + grad[0]=-400 * x * (y - x * x) - 2 * (1 - x); + grad[1]=200 * (y - x * x); + return grad; + } + + + void Minimization() + { + ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); + //passing RosenBrock function to R + r["RosenBrock"]< http://oproject.org/tiki-index.php?page=ROOT+R+Users+Guide
+ https://root.cern.ch/drupal/content/how-use-r-root-root-r-interface + + @ingroup R + */ + + class TRInterface; class TRFunctionExport: public TObject { friend class TRInterface; friend SEXP Rcpp::wrap(const TRFunctionExport &f); protected: - TRInternalFunction *f; + TRInternalFunction *f; //Internar Function to export public: + /** + Default TRFunctionExport constructor + */ TRFunctionExport(); - + /** + TRFunctionExport copy constructor + \param fun other TRFunctionExport + */ TRFunctionExport(const TRFunctionExport &fun); - //________________________________________________________________________________________________________ - template TRFunctionExport(T fun) { + + /** + TRFunctionExport template constructor + \param fun supported function to be wrapped by Rcpp + */ + template TRFunctionExport(T fun) + { //template constructor that supports a lot // of function's prototypes f = new TRInternalFunction(fun); } - //________________________________________________________________________________________________________ - template void SetFunction(T fun) { + /** + function to assign function to export + \param fun supported function to be wrapped by Rcpp + */ + template void SetFunction(T fun) + { //template method that supports a lot // of function's prototypes f = new TRInternalFunction(fun); diff --git a/bindings/r/inc/TRFunctionImport.h b/bindings/r/inc/TRFunctionImport.h index e37d1bd1fa84e..406dbfe88121b 100644 --- a/bindings/r/inc/TRFunctionImport.h +++ b/bindings/r/inc/TRFunctionImport.h @@ -25,17 +25,100 @@ #include #endif -//________________________________________________________________________________________________________ -/** - This is a base class to pass functions from ROOT to R - - - @ingroup R -*/ namespace ROOT { namespace R { + /** + This is a class to pass functions from ROOT to R + +

TRFunctionImport class

+

+ The TRFunctionImport class lets you call R's functions to ROOT's environment
+ The object associated to this class have a set of overloaded operators to use the object like function
+

+ \code{.cpp} + #include + + using namespace ROOT::R; + void Function() + { + TRInterface &r = TRInterface::Instance(); + r.SetVerbose(1); + //////////////////////////////////////// + //defining functions to be used from R// + //////////////////////////////////////// + TRFunctionImport c("c"); + TRFunctionImport list("list"); + TRFunctionImport asformula("as.formula"); + TRFunctionImport nls("nls"); + TRFunctionImport confint("confint"); + TRFunctionImport summary("summary"); + TRFunctionImport print("print"); + TRFunctionImport plot("plot"); + TRFunctionImport lines("lines"); + TRFunctionImport devnew("dev.new"); + TRFunctionImport devoff("dev.off"); + TRFunctionImport min("min"); + TRFunctionImport max("max"); + TRFunctionImport seq("seq"); + TRFunctionImport predict("predict"); + + r<<"options(device='png')";//enable plot in png file + + //////////////////////// + //doing the procedure // + //////////////////////// + TRObject xdata = c(-2,-1.64,-1.33,-0.7,0,0.45,1.2,1.64,2.32,2.9); + TRObject ydata = c(0.699369,0.700462,0.695354,1.03905,1.97389,2.41143,1.91091,0.919576,-0.730975,-1.42001); + + TRDataFrame data; + data["xdata"]=xdata; + data["ydata"]=ydata; + + //fit = nls(ydata ~ p1*cos(p2*xdata) + p2*sin(p1*xdata), start=list(p1=1,p2=0.2)) <- R code + TRObject fit = nls(asformula("ydata ~ p1*cos(p2*xdata) + p2*sin(p1*xdata)"),Label["data"]=data, Label["start"]=list(Label["p1"]=1,Label["p2"]=0.2)); + print(summary(fit)); + + print(confint(fit)); + + devnew("Fitting Regression"); + plot(xdata,ydata); + + TRObject xgrid=seq(min(xdata),max(xdata),Label["len"]=10); + lines(xgrid,predict(fit,xgrid),Label["col"] = "green"); + devoff(); + } + \endcode + + Output + \code + Formula: ydata ~ p1 * cos(p2 * xdata) + p2 * sin(p1 * xdata) + + Parameters: + Estimate Std. Error t value Pr(>|t|) + p1 1.881851 0.027430 68.61 2.27e-12 *** + p2 0.700230 0.009153 76.51 9.50e-13 *** + --- + Signif. codes: 0 ā€˜***’ 0.001 ā€˜**’ 0.01 ā€˜*’ 0.05 ā€˜.’ 0.1 ā€˜ ’ 1 + + Residual standard error: 0.08202 on 8 degrees of freedom + + Number of iterations to convergence: 7 + Achieved convergence tolerance: 2.189e-06 + + Waiting for profiling to be done... + 2.5% 97.5% + p1 1.8206081 1.9442365 + p2 0.6794193 0.7209843 + \endcode +

Users Guide

+ http://oproject.org/tiki-index.php?page=ROOT+R+Users+Guide
+ https://root.cern.ch/drupal/content/how-use-r-root-root-r-interface + + @ingroup R + */ + class TRInterface; class TRFunctionImport: public TObject { friend class TRInterface; @@ -43,20 +126,49 @@ namespace ROOT { friend TRFunctionImport Rcpp::as<>(SEXP); protected: - Rcpp::Function *f; - TRFunctionImport(const Rcpp::Function &fun){ - *f=fun; + Rcpp::Function *f;//Internal Rcpp function to import + /** + TRFunctionImport constructor for Rcpp::DataFrame + \param fun raw function object from Rcpp + */ + + TRFunctionImport(const Rcpp::Function &fun) + { + *f = fun; } - + public: - TRFunctionImport(const TString& name); - TRFunctionImport(const TString& name, const TString& ns); - TRFunctionImport(const TRFunctionImport &fun); - TRFunctionImport(SEXP obj); - - ~TRFunctionImport(){if(f) delete f;} - SEXP operator()(){return (*f)();} - #include + /** + TRFunctionImport constructor + \param name name of function from R + */ + TRFunctionImport(const TString &name); + /** + TRFunctionImport constructor + \param name name of function from R + \param ns namespace of function from R + */ + TRFunctionImport(const TString &name, const TString &ns); + /** + TRFunctionImport copy constructor + \param fun other TRFunctionImport + */ + TRFunctionImport(const TRFunctionImport &fun); + /** + TRFunctionImport constructor + \param obj raw R object + */ + TRFunctionImport(SEXP obj); + + ~TRFunctionImport() + { + if (f) delete f; + } + SEXP operator()() + { + return (*f)(); + } +#include ClassDef(TRFunctionImport, 0) // }; } diff --git a/bindings/r/inc/TRInterface.h b/bindings/r/inc/TRInterface.h index bb827cec92718..b108bb6f1d96b 100644 --- a/bindings/r/inc/TRInterface.h +++ b/bindings/r/inc/TRInterface.h @@ -32,19 +32,7 @@ #include #endif -/** - @defgroup R R Interface for Statistical Computing - \ref ROOTR was implemented using the - R Project library and the modules - Rcpp and - RInside - @ingroup R - */ -/** - @defgroup R R Interface for Statistical Computing - @ingroup R - */ ////////////////////////////////////////////////////////////////////////// // // @@ -56,6 +44,21 @@ namespace ROOT { namespace R { +/** + @defgroup R R Interface for Statistical Computing + */ + +/** + ROOT R was implemented using the + R Project library and the modules + Rcpp and + RInside +

Users Guide

+ http://oproject.org/tiki-index.php?page=ROOT+R+Users+Guide
+ https://root.cern.ch/drupal/content/how-use-r-root-root-r-interface + + @ingroup R + */ class TRInterface: public TObject { protected: RInside *fR; diff --git a/bindings/r/inc/TRObject.h b/bindings/r/inc/TRObject.h index 76011f792587c..d9505d01aad76 100644 --- a/bindings/r/inc/TRObject.h +++ b/bindings/r/inc/TRObject.h @@ -15,146 +15,178 @@ #include #endif -//________________________________________________________________________________________________________ -/** - -This is a class to get ROOT's objects from R's objects -

TRObject class

- -

-The TRObject class lets you obtain ROOT's objects from R's objects.
-It has some basic template opetarors to convert R's objects into ROOT's datatypes
-

-A simple example
-

- -

- -\code{.cpp} -#include -void Proxy() -{ -ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -ROOT::R::TRObject obj; -obj=r.Eval("seq(1,10)"); -TVectorD v=obj; -v.Print(); -} -\endcode - @ingroup R -*/ namespace ROOT { namespace R { + + /** + + This is a class to get ROOT's objects from R's objects +

TRObject class

+ +

+ The TRObject class lets you obtain ROOT's objects from R's objects.
+ It has some basic template opetarors to convert R's objects into ROOT's datatypes
+

+ A simple example
+

+ +

+ + \code{.cpp} + #include + void Proxy() + { + ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); + ROOT::R::TRObject obj; + obj=r.Eval("seq(1,10)"); + TVectorD v=obj; + v.Print(); + } + \endcode + Output + \code + + Vector (10) is as follows + + | 1 | + ------------------ + 0 |1 + 1 |2 + 2 |3 + 3 |4 + 4 |5 + 5 |6 + 6 |7 + 7 |8 + 8 |9 + 9 |10 + + \endcode + +

Users Guide

+ http://oproject.org/tiki-index.php?page=ROOT+R+Users+Guide
+ https://root.cern.ch/drupal/content/how-use-r-root-root-r-interface + + @ingroup R + */ class TRObject: public TObject { - friend SEXP Rcpp::wrap(const TRObject &f); + friend SEXP Rcpp::wrap(const TRObject &f); private: Rcpp::RObject fObj; //insternal Rcpp::RObject Bool_t fStatus;//status tell if is a valid object public: - /** - Construct a TRObject - */ + /** + Default constructor + */ TRObject(): TObject() {}; - /** - Construct a TRObject given a R base object - \param robj raw R object - */ + /** + Construct a TRObject given a R base object + \param robj raw R object + */ TRObject(SEXP robj); - /** - Construct a TRObject given a R base object - \param robj raw R object - \param status if the raw object is valid obj - */ + /** + Construct a TRObject given a R base object + \param robj raw R object + \param status if the raw object is valid obj + */ TRObject(SEXP robj, Bool_t status); - - /** - TRObject is a current valid object? - \param status if the current object is valid obj - */ - void SetStatus(Bool_t status){ fStatus = status;} - - /** - TRObject is a current valid object? - \return status if the current object - */ - Bool_t GetStatus() { return fStatus;} - - /** - The R objects can to have associate attributes - with this method you can added attribute to TRObject given an object in the template argument. - \param name attribute name - \param obj object associated to the attribute name in the current TRObject - */ - template void SetAttribute(const TString name,T obj) + + /** + TRObject is a current valid object? + \param status if the current object is valid obj + */ + void SetStatus(Bool_t status) + { + fStatus = status; + } + + /** + TRObject is a current valid object? + \return status if the current object + */ + Bool_t GetStatus() + { + return fStatus; + } + + /** + The R objects can to have associate attributes + with this method you can added attribute to TRObject given an object in the template argument. + \param name attribute name + \param obj object associated to the attribute name in the current TRObject + */ + template void SetAttribute(const TString name, T obj) { - fObj.attr(name.Data())=obj; + fObj.attr(name.Data()) = obj; } - - /** - The R objects can to have associate attributes - with this method you can added attribute to TRObject given an object in the template argument. - \param name attribute name - \return object associated to the attribute name in the current TRObject - */ + + /** + The R objects can to have associate attributes + with this method you can added attribute to TRObject given an object in the template argument. + \param name attribute name + \return object associated to the attribute name in the current TRObject + */ TRObject GetAttribute(const TString name) { - return fObj.attr(name.Data()); + return fObj.attr(name.Data()); } - + void operator=(SEXP xx); - /** - Some datatypes of ROOT or c++ can be wrapped in to a TRObject, - this method lets you wrap those datatypes - \param obj template object to be wrapped - \return TRObject reference of wrapped object - */ - template TRObject& Wrap(T obj) { - fObj=::Rcpp::wrap(obj); - return *this; + /** + Some datatypes of ROOT or c++ can be wrapped in to a TRObject, + this method lets you wrap those datatypes + \param obj template object to be wrapped + \return TRObject reference of wrapped object + */ + template TRObject &Wrap(T obj) + { + fObj =::Rcpp::wrap(obj); + return *this; } - - /** - Some datatypes of ROOT or c++ can be wrapped in to a TRObject, - this method lets you unwrap those datatypes encapsulate into this TRObject. - \note If the current TRObject is not a valid object it will return and empty object and it will print an error message - \return template return with the require datatype - */ - template T As() { - if(fStatus) - { - T data=::Rcpp::as(fObj); - return data; - }else - { - Error("Cast Operator", "Can not make the requested data, returning an unknow value"); - return T(); - } + + /** + Some datatypes of ROOT or c++ can be wrapped in to a TRObject, + this method lets you unwrap those datatypes encapsulate into this TRObject. + \note If the current TRObject is not a valid object it will return and empty object and it will print an error message + \return template return with the require datatype + */ + template T As() + { + if (fStatus) { + T data =::Rcpp::as(fObj); + return data; + } else { + Error("Cast Operator", "Can not make the requested data, returning an unknow value"); + return T(); + } } - template T operator=(TRObject &obj) { + template T operator=(TRObject &obj) + { return ::Rcpp::as(obj); } - operator SEXP() { - return fObj; - } - - operator Rcpp::RObject() { - return fObj; - } - - template operator T() { - - if(fStatus) - { - T data=::Rcpp::as(fObj); - return data; - }else - { - Error("Cast Operator", "Can not make the requested data, returning an unknow value"); - return T(); - } + operator SEXP() + { + return fObj; + } + + operator Rcpp::RObject() + { + return fObj; + } + + template operator T() + { + + if (fStatus) { + T data =::Rcpp::as(fObj); + return data; + } else { + Error("Cast Operator", "Can not make the requested data, returning an unknow value"); + return T(); + } } ClassDef(TRObject, 0) // }; diff --git a/bindings/r/src/TRDataFrame.cxx b/bindings/r/src/TRDataFrame.cxx index 04dfa9bf50bdd..8d2638e64f9c2 100644 --- a/bindings/r/src/TRDataFrame.cxx +++ b/bindings/r/src/TRDataFrame.cxx @@ -6,29 +6,25 @@ * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #include -//////////////////////////////////////////////////////////////////////////////// using namespace ROOT::R; ClassImp(TRDataFrame) -//////////////////////////////////////////////////////////////////////////////// - +//______________________________________________________________________________ TRDataFrame::TRDataFrame(): TObject() { df = Rcpp::DataFrame::create(); } -//////////////////////////////////////////////////////////////////////////////// - +//______________________________________________________________________________ TRDataFrame::TRDataFrame(const TRDataFrame &_df): TObject(_df) { df = _df.df; } -//////////////////////////////////////////////////////////////////////////////// - +//______________________________________________________________________________ TRDataFrame::Binding TRDataFrame::operator[](const TString &name) { return Binding(df,name); diff --git a/bindings/r/src/TRFunctionExport.cxx b/bindings/r/src/TRFunctionExport.cxx index 9fbaa4aff1595..4ad85be1d2ba6 100644 --- a/bindings/r/src/TRFunctionExport.cxx +++ b/bindings/r/src/TRFunctionExport.cxx @@ -6,111 +6,6 @@ * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #include -//______________________________________________________________________________ -/* Begin_Html -

TRFunctionExport class

- -

-The TRFunctionExport class lets you pass ROOT's functions to R's environment
-

-

-The next example was based in
- -http://root.cern.ch/root/html/tutorials/fit/NumericalMinimization.C.html -
- -http://stat.ethz.ch/R-manual/R-devel/library/stats/html/optim.html
- -

-End_Html -Begin_Latex - -Let f(x,y)=(x-1)^{2} + 100(y-x^{2})^{2}, which is called the Rosenbrock -function. - -It's known that this function has a minimum when y = x^{2} , and x = 1. -Let's get the minimum using R's optim package through ROOTR's interface. -In the code this function was called "Double_t RosenBrock(const TVectorD xx )", because for -optim, the input in your function definition must be a single vector. - - -The Gradient is formed by -#frac{#partial f}{#partial x} = -400x(y - x^{2}) - 2(1 - x) - -#frac{#partial f}{#partial y} = 200(y - x^{2}); - -The "TVectorD RosenBrockGrad(const TVectorD xx )" function -must have a single vector as the argument a it will return a single vetor. - -End_Latex -Begin_Html -
-End_Html - -#include - -//in the next function the pointer *double must be changed by TVectorD, because the pointer has no -//sense in R's environment. -Double_t RosenBrock(const TVectorD xx ) -{ - const Double_t x = xx[0]; - const Double_t y = xx[1]; - const Double_t tmp1 = y-x*x; - const Double_t tmp2 = 1-x; - return 100*tmp1*tmp1+tmp2*tmp2; -} - -TVectorD RosenBrockGrad(const TVectorD xx ) -{ - const Double_t x = xx[0]; - const Double_t y = xx[1]; - TVectorD grad(2); - grad[0]=-400 * x * (y - x * x) - 2 * (1 - x); - grad[1]=200 * (y - x * x); - return grad; -} - - -void Minimization() -{ - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - //passing RosenBrock function to R - r["RosenBrock"]< https://root.cern.ch/drupal/content/how-use-r-root-root-r-interface @ingroup R + */ + + +/** +

TRInterface class

+ +

+The TRInterface class lets you procces R code from ROOT.
+You can call R libraries and their functions, plot results in R or ROOT,
+and use the power of ROOT and R at the same time.
+It also lets you pass scalars, vectors and matrices from ROOT to R
+and from R to ROOT using TRObject; but you can to use overloaded opetarors [],<< and >>
+to work with ROOTR like work with streams of data.
+ +TRInterface class can not be instantiated directly, but you can create objects using the static methods +TRInterface& Instance() and TRInterface* InstancePtr() to create your own objects.
+
+

+Show an example below: +Create an exponential fit, the idea is to create a set of numbers x,y with noise from ROOT, +pass them to R and fit the data to \f$ x^3 \f$, get the fitted coefficient(power) and plot the data, +the known function and the fitted function. +\code{.cpp} + + TCanvas *c1 = new TCanvas("c1","Curve Fit",700,500); + c1->SetGrid(); + + // draw a frame for multiples graphs + TMultiGraph *mg = new TMultiGraph(); + + // create the first graph (points with gaussian noise) + const Int_t n = 24; + Double_t x[n] ; + Double_t y[n] ; + //Generate points along a X^3 with noise + TRandom rg; + rg.SetSeed(520); + for (Int_t i = 0; i < n; i++) { + x[i] = rg.Uniform(0, 1); + y[i] = TMath::Power(x[i], 3) + rg.Gaus() * 0.06; + } + + TGraph *gr1 = new TGraph(n,x,y); + gr1->SetMarkerColor(kBlue); + gr1->SetMarkerStyle(8); + gr1->SetMarkerSize(1); + mg->Add(gr1); + + // create second graph + TF1 *f_known=new TF1("f_known","pow(x,3)",0,1); + TGraph *gr2 = new TGraph(f_known); + gr2->SetMarkerColor(kRed); + gr2->SetMarkerStyle(8); + gr2->SetMarkerSize(1); + mg->Add(gr2); + + //passing x and y values to R for fitting + ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); + r["x"]<>power; + + TF1 *f_fitted=new TF1("f_fitted","pow(x,[0])",0,1); + f_fitted->SetParameter(0,power); + //plotting the fitted function + TGraph *gr3 = new TGraph(f_fitted); + gr3->SetMarkerColor(kGreen); + gr3->SetMarkerStyle(8); + gr3->SetMarkerSize(1); + + mg->Add(gr3); + mg->Draw("ap"); + + //displaying basic results + TPaveText *pt = new TPaveText(0.1,0.6,0.5,0.9,"brNDC"); + pt->SetFillColor(18); + pt->SetTextAlign(12); + pt->AddText("Fitting x^power "); + pt->AddText(" \"Blue\" Points with gaussian noise to be fitted"); + pt->AddText(" \"Red\" Known function x^3"); + TString fmsg; + fmsg.Form(" \"Green\" Fitted function with power=%.4lf",power); + pt->AddText(fmsg); + pt->Draw(); + c1->Update(); +\endcode +@ingroup R */ class TRInterface: public TObject { protected: @@ -122,32 +206,97 @@ namespace ROOT { public: ~TRInterface(); + /** + Method to set verbose mode, that produce extra output + \note some time can produce so much noise in the output + \param status boolean to enable of disable + */ void SetVerbose(Bool_t status); + /** + Method to eval R code and you get the result in a reference to TRObject + \param code R code + \param ands reference to TRObject + \return an true or false if the execution was sucessful or not. + */ Int_t Eval(const TString &code, TRObject &ans); // parse line, returns in ans; error code rc - + /** + Method to eval R code + \param code R code + */ void Execute(const TString &code); + /** + Method to eval R code and you get the result in a TRObject + \param code R code + \return a TRObject with result + */ TRObject Eval(const TString &code); - static void LoadModule(TString name); - //______________________________________________________________________________ + /** + Template method to assign C++ variables into R enviroment + \param var any R wrappable datatype + \param name name of the variable in R's enviroment + */ templatevoid Assign(const T &var, const TString &name) { // This method lets you pass variables from ROOT to R. // The template T should be a supported ROOT datatype and // the TString's name is the name of the variable in the R enviroment. fR->assign(var, name.Data()); } + /** + Method to assign TRFunctionExport in R's enviroment + \param fun TRFunctionExport + \param name name of the variable in R's enviroment + */ void Assign(const TRFunctionExport &fun, const TString &name); + /** + Method to assign TRDataFrame in R's enviroment + \param df TRDataFrame + \param name name of the variable in R's enviroment + */ void Assign(const TRDataFrame &df, const TString &name); + /** + Method to get a R prompt to work interactively with tab completation support + */ void Interactive(); + + /** + Init event loop in a thread to support actions in windows from R graphics system + */ void ProcessEventsLoop(); + + /** + Method to verify if a package is installed + \param pkg R's pkg name + \return true or false if the package is installed or not + */ Bool_t IsInstalled(TString pkg); + /** + Method to load an R's package + \param pkg R's pkg name + \return true or false if the package was loaded or not + */ Bool_t Require(TString pkg); + /** + Method to install an R's package + \param pkg R's pkg name + \param repos url for R's package repository + \return true or false if the package was installed or not + */ Bool_t Install(TString pkg,TString repos="http://cran.r-project.org"); Binding operator[](const TString &name); + + /** + static method to get an TRInterface instance reference + \return TRInterface instance reference + */ static TRInterface &Instance(); + /** + static method to get an TRInterface instance pointer + \return TRInterface instance pointer + */ static TRInterface *InstancePtr(); ClassDef(TRInterface, 0) diff --git a/bindings/r/src/TRInterface.cxx b/bindings/r/src/TRInterface.cxx index c81ced789f929..7264849703318 100644 --- a/bindings/r/src/TRInterface.cxx +++ b/bindings/r/src/TRInterface.cxx @@ -16,105 +16,6 @@ extern "C" } #include -//////////////////////////////////////////////////////////////////////////////// - -/* Begin_Html -

TRInterface class

- -

-The TRInterface class lets you procces R code from ROOT.
-You can call R libraries and their functions, plot results in R or ROOT,
-and use the power of ROOT and R at the same time.
-It also lets you pass scalars, vectors and matrices from ROOT to R
-and from R to ROOT using TRObject; but you can to use overloaded opetarors [],<< and >>
-to work with ROOTR like work with streams of data.
- -TRInterface class can not be instantiated directly, but you can create objects using the static methods -TRInterface& Instance() and TRInterface* InstancePtr() to create your own objects.
-
-

-Show an example below: -End_Html -Begin_Macro(source) -{ - -//Create an exponential fit -//The idea is to create a set of numbers x,y with noise from ROOT, -//pass them to R and fit the data to x^3, -//get the fitted coefficient(power) and plot the data, -//the known function and the fitted function. -//Author:: Omar Zapata - TCanvas *c1 = new TCanvas("c1","Curve Fit",700,500); - c1->SetGrid(); - - // draw a frame for multiples graphs - TMultiGraph *mg = new TMultiGraph(); - - // create the first graph (points with gaussian noise) - const Int_t n = 24; - Double_t x[n] ; - Double_t y[n] ; - //Generate points along a X^3 with noise - TRandom rg; - rg.SetSeed(520); - for (Int_t i = 0; i < n; i++) { - x[i] = rg.Uniform(0, 1); - y[i] = TMath::Power(x[i], 3) + rg.Gaus() * 0.06; - } - - TGraph *gr1 = new TGraph(n,x,y); - gr1->SetMarkerColor(kBlue); - gr1->SetMarkerStyle(8); - gr1->SetMarkerSize(1); - mg->Add(gr1); - - // create second graph - TF1 *f_known=new TF1("f_known","pow(x,3)",0,1); - TGraph *gr2 = new TGraph(f_known); - gr2->SetMarkerColor(kRed); - gr2->SetMarkerStyle(8); - gr2->SetMarkerSize(1); - mg->Add(gr2); - - //passing x and y values to R for fitting - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - r["x"]<>power; - - TF1 *f_fitted=new TF1("f_fitted","pow(x,[0])",0,1); - f_fitted->SetParameter(0,power); - //plotting the fitted function - TGraph *gr3 = new TGraph(f_fitted); - gr3->SetMarkerColor(kGreen); - gr3->SetMarkerStyle(8); - gr3->SetMarkerSize(1); - - mg->Add(gr3); - mg->Draw("ap"); - - //displaying basic results - TPaveText *pt = new TPaveText(0.1,0.6,0.5,0.9,"brNDC"); - pt->SetFillColor(18); - pt->SetTextAlign(12); - pt->AddText("Fitting x^power "); - pt->AddText(" \"Blue\" Points with gaussian noise to be fitted"); - pt->AddText(" \"Red\" Known function x^3"); - TString fmsg; - fmsg.Form(" \"Green\" Fitted function with power=%.4lf",power); - pt->AddText(fmsg); - pt->Draw(); - c1->Update(); - return c1; -} -End_Macro */ - using namespace ROOT::R; ClassImp(TRInterface) @@ -149,43 +50,6 @@ TRInterface::~TRInterface() if (th) delete th; } -void TRInterface::LoadModule(TString name) -{ - //Method to load wrapped ROOT's classes into R's environment - //e.g: r.LoadModule("Hist") load the current(partially) wrapped classes TF1 and TGraph - if (name == "Hist") { - gApplication->ProcessLine("#include"); - gApplication->ProcessLine("LOAD_ROOTR_MODULE(ROOTR_TRF1);"); - gR->Execute("TF1 <- .GlobalEnv$.__C__Rcpp_TRF1"); - - gApplication->ProcessLine("#include"); - gApplication->ProcessLine("LOAD_ROOTR_MODULE(ROOTR_TRGraph);"); - gR->Execute("TGraph <- .GlobalEnv$.__C__Rcpp_TRGraph"); - - } - if (name == "Gpad") { - gApplication->ProcessLine("#include"); - gApplication->ProcessLine("LOAD_ROOTR_MODULE(ROOTR_TRCanvas);"); - gR->Execute("TCanvas <- .GlobalEnv$.__C__Rcpp_TRCanvas"); - } - if (name == "Rint") { - gApplication->ProcessLine("#include"); - gApplication->ProcessLine("LOAD_ROOTR_MODULE(ROOTR_TRRint);"); - gR->Execute("TRint <- .GlobalEnv$.__C__Rcpp_TRRint"); - } - if (name == "Core") { - gApplication->ProcessLine("#include"); - gApplication->ProcessLine("LOAD_ROOTR_MODULE(ROOTR_TRSystem);"); - } - if (name == "IO") { - gApplication->ProcessLine("#include"); - gApplication->ProcessLine("LOAD_ROOTR_MODULE(ROOTR_TRFile);"); - gR->Execute("TFile <- .GlobalEnv$.__C__Rcpp_TRFile"); - } - -} - - //______________________________________________________________________________ Int_t TRInterface::Eval(const TString &code, TRObject &ans) { From 8f4ea50168fc047631bd6c31f5b6ca0d68259034 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mesa Date: Sun, 2 Aug 2015 23:24:23 -0500 Subject: [PATCH 17/21] ROOTR: fixed markdown users guide to support github and doxygen syntax, added entry to generate doxugen doc for ROOT R in documentation/doxygen/Doxyfile --- .../r/doc/users-guide/ROOTR Users Guide.md | 136 +++++++++--------- documentation/doxygen/Doxyfile | 5 +- 2 files changed, 71 insertions(+), 70 deletions(-) diff --git a/bindings/r/doc/users-guide/ROOTR Users Guide.md b/bindings/r/doc/users-guide/ROOTR Users Guide.md index fda75d9d86793..9e5c8492421ec 100644 --- a/bindings/r/doc/users-guide/ROOTR Users Guide.md +++ b/bindings/r/doc/users-guide/ROOTR Users Guide.md @@ -36,36 +36,36 @@ To install ROOTR please read first. To compile with cmake added into ~/.profile -``` {.sh} +~~~{.sh} export PATH=$PATH:/Applications/CMake.app/Contents/bin/ -``` +~~~ and -``` {.sh} +~~~{.sh} source ~/.profile -``` +~~~ Install needed R packages, open R and in the prompt type -``` {.sh} +~~~{.sh} install.packages(c('Rcpp','RInside')) -``` +~~~ select a mirror and install. Download code from git repo -``` {.sh} +~~~{.sh} git clone -b master-root-R https://github.com/lmoneta/root.git -``` +~~~ To compile ROOTR lets to create a compilation directory and to activate it use cmake -Dr=ON .. -``` {.sh} +~~~{.sh} mkdir compile cd compile cmake -Dr=ON .. make -j n -``` +~~~ This is a basic video using ROOTR on ![ROOTR Mac](http://img.youtube.com/vi/tvhuEen8t7c/0.jpg)](http://www.youtube.com/watch?v=tvhuEen8t7c) @@ -77,29 +77,29 @@ This is a basic video using ROOTR on install (For debian-based distros) -``` {.sh} +~~~{.sh} apt-get install r-base r-base-dev -``` +~~~ Install needed R packages, open R and in the prompt type -``` {.sh} +~~~{.sh} install.packages(c('Rcpp','RInside')) -``` +~~~ select a mirror and install. Download code from git repo -``` {.sh} +~~~{.sh} git clone -b master-root-R https://github.com/lmoneta/root.git -``` +~~~ To compile ROOTR lets to create a compilation directory and to activate it use cmake -Dr=ON .. -``` {.sh} +~~~{.sh} mkdir compile cd compile cmake -Dr=ON .. make -j n -``` +~~~ This is a basic video using ROOTR on ![ROOTR Gnu/Linux](http://img.youtube.com/vi/FkrmM2xCPoM/0.jpg)](http://www.youtube.com/watch?v=FkrmM2xCPoM) @@ -111,16 +111,16 @@ of making calls to R to give and obtein data. This class has a series of overcha and code from R to C++ and vice versa. To create an object of this class the user must use the static methods `ROOT::R::TRInterface::Instance` and `ROOT::R::TRInterface::InstancePtr` which return a reference object and a pointer object respectively. -``` {.cpp} +~~~{.cxx} #include ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -``` +~~~ ## Running R code and passing/getting variables. We have different ways to run R code and pass/obtain data to/from R environment: using the methods Execute(code) and Eval(code). -``` {.cpp} +~~~{.cxx} #include //creating an instance @@ -143,12 +143,12 @@ std::vector vd(3); r["seq(0,1,0.5)"]>>vd; std::cout< v(3); -v[0]=0; -v[1]=1; -v[2]=2; +std::vector v1(3); +v1[0]=0; +v1[1]=1; +v1[2]=2; -r["v1"]<>m; m.Print(); -``` +~~~ So, working with ROOTR is like working with flows of data to pass, obtain and process data. ## Passing functions from ROOT to R @@ -166,7 +166,7 @@ So instead of using `*Double_t` you must use `std::vector` and instead of `*Char For this example we need to create a macro, so save it as fun.C -``` {.cpp} +~~~{.cxx} #include #include @@ -183,14 +183,14 @@ Double_t myfun2(std::vector x) //use std::vector instead Dou void fun() { ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -r["dilog"]< Double_t myfun(Double_t x) @@ -220,7 +220,7 @@ r["myfuni"]<<(Int_t (*)(Int_t))myfun; r<<"print(myfund(0.0))"; r<<"print(myfuni(1))"; } -``` +~~~ ## Wrapping a class You can wrap a class and expose it in R environment using only a pair of macrodefinitions and the template class @@ -240,7 +240,7 @@ Example: Lets to create need data to play with dataframe features -``` {.cpp} +~~~{.cxx} //////////////////////// //creating variables// //////////////////////// @@ -265,11 +265,11 @@ names.push_back("v2"); names.push_back("v3"); ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -``` +~~~ In R the dataframe have associate to every column a label, in ROOTR you can have the same label using the class ROOT::R::Label to create a TRDataFrame where you data have a label associate. -``` {.cpp} +~~~{.cxx} ///////////////////////////////////////////////// //creating dataframe object with its labels// ///////////////////////////////////////////////// @@ -282,18 +282,18 @@ ROOT::R::TRDataFrame df1(ROOT::R::Label["var1"]=v1,ROOT::R::Label["var2"]=v2,RO r["df1"]<>v; v.Print(); -``` +~~~ Output -``` {.sh} +~~~{.sh} Vector (3) is as follows | 1 | @@ -354,9 +354,9 @@ Vector (3) is as follows 0 |3 1 |2 2 |1 -``` +~~~ -``` {.cpp} +~~~{.cxx} /////////////////////////////////////////// //Working with colunms between dataframes// /////////////////////////////////////////// @@ -366,17 +366,17 @@ df2["v3"]<>df1["var1"]; //updating df1 in R's environment r["df1"]< root [1] ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); @@ -434,7 +434,7 @@ Vector (9) is as follows 8 |5 root [4] -``` +~~~ ## EXAMPLES The examples can also be found in `$ROOTSYS/tutorials/r` @@ -445,7 +445,7 @@ associated to that function are needed. In this example I show how to give support to a custom class to be used in R's environment, which at the same time is a functor. -``` {.cpp} +~~~{.cxx} #include #include @@ -521,7 +521,7 @@ void Functor() r<<"print(sprintf('value in R = %f',functor$doEval( 1 )))"; std::cout<<"value in ROOT = "< #include @@ -603,7 +603,7 @@ TCanvas *SimpleFitting(){ c1->Update(); return c1; } -``` +~~~ In the first image you can see the blue dots wichi are the function `x^3` with gaussian noise, the red dots correspond to the original function and the green ones correspond to the fitted function.
![](img/simplefit.gif)
@@ -613,15 +613,15 @@ DEoptim is a R package for Differential Evolution Minimization that lets you do Minimization. To install this package you just need to run: -``` {.cpp} +~~~{.cxx} #include ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); r<<"install.packages('DEoptim',repos='http://cran.rstudio.com/')"; -``` +~~~ Then create a macro named GlobalMinimization.C with the next code. -``` {.cpp} +~~~{.cxx} #include #include #include @@ -717,7 +717,7 @@ void GlobalMinimization() r<<"dev.new(title='Rastrigin Convergence')"; r<<"plot(result2,type='o',pch='.')"; } -``` +~~~ In the image you can see the convergence plots of the functions and their minimum. For RosenBrock is (1,1,1) and for Rastrigin is (0,0,0).
![](img/minimization.jpeg)
@@ -729,7 +729,7 @@ graphical functions. More Information on R interpolation at [http://stat.ethz.ch/R-manual/R-patched/library/stats/html/approxfun.html](http://stat.ethz.ch/R-manual/R-patched/library/stats/html/approxfun.html) -``` {.cpp} +~~~{.cxx} #include #include #include @@ -778,14 +778,14 @@ r<<"curve(fc(x), 0, 10, col = 'darkblue', add = TRUE)"; // different interpolation on left and right side : r<<"plot(approxfun(x, y, rule = 2:1), 0, 11,col = 'tomato', add = TRUE, lty = 3, lwd = 2)"; } -``` +~~~ The image shows the interpolated function plotted within R
![](img/interpolation.png)
## Integration (Passing vectorized function to R) Numerical integration using R passing the function from ROOT -``` {.cpp} +~~~{.cxx} #include #include #include @@ -838,7 +838,7 @@ void Integration() std::cout<<"Integral of BreitWigner Function in the interval [-Inf, Inf] R = "< Date: Mon, 3 Aug 2015 01:22:40 -0500 Subject: [PATCH 18/21] ROOTR: small fixes in doc generation, all working very fine. --- .../r/doc/users-guide/ROOTR Users Guide.md | 11 +++++--- bindings/r/inc/TRDataFrame.h | 3 ++- bindings/r/inc/TRFunctionExport.h | 2 +- bindings/r/inc/TRFunctionImport.h | 1 + bindings/r/inc/TRInterface.h | 22 +++++++++++----- bindings/r/inc/TRObject.h | 2 +- bindings/r/src/TRInterface.cxx | 26 ++++++------------- documentation/doxygen/Doxyfile | 8 +++--- 8 files changed, 40 insertions(+), 35 deletions(-) diff --git a/bindings/r/doc/users-guide/ROOTR Users Guide.md b/bindings/r/doc/users-guide/ROOTR Users Guide.md index 9e5c8492421ec..5bde4993afa60 100644 --- a/bindings/r/doc/users-guide/ROOTR Users Guide.md +++ b/bindings/r/doc/users-guide/ROOTR Users Guide.md @@ -1,4 +1,4 @@ -
![](img/logo.jpeg)
+![](img/logo.jpeg) # ROOTR Users Guide @@ -606,7 +606,7 @@ TCanvas *SimpleFitting(){ ~~~ In the first image you can see the blue dots wichi are the function `x^3` with gaussian noise, the red dots correspond to the original function and the green ones correspond to the fitted function. -
![](img/simplefit.gif)
+![](img/simplefit.gif) ## Global Minimization in R using the package DEoptim DEoptim is a R package for Differential Evolution Minimization that lets you do global @@ -720,7 +720,7 @@ void GlobalMinimization() ~~~ In the image you can see the convergence plots of the functions and their minimum. For RosenBrock is (1,1,1) and for Rastrigin is (0,0,0). -
![](img/minimization.jpeg)
+![](img/minimization.jpeg) ## Interpolation (Plotting in R) This example shows an interpolation using the function aproxfun and how to make a plot with R's @@ -780,7 +780,7 @@ r<<"plot(approxfun(x, y, rule = 2:1), 0, 11,col = 'tomato', add = TRUE, lty = 3, } ~~~ The image shows the interpolated function plotted within R -
![](img/interpolation.png)
+![](img/interpolation.png) ## Integration (Passing vectorized function to R) Numerical integration using R passing the function from ROOT @@ -840,5 +840,8 @@ void Integration() } ~~~ +## Users Guide Sites +- http://oproject.org/tiki-index.php?page=ROOT+R+Users+Guide +- https://root.cern.ch/drupal/content/how-use-r-root-root-r-interface diff --git a/bindings/r/inc/TRDataFrame.h b/bindings/r/inc/TRDataFrame.h index 373880c756104..7b0e64a8f2d0d 100644 --- a/bindings/r/inc/TRDataFrame.h +++ b/bindings/r/inc/TRDataFrame.h @@ -29,7 +29,8 @@ namespace ROOT { namespace R { /** - + \class TRDataFrame + This is a class to create DataFrames from ROOT to R

TRDataFrame class

diff --git a/bindings/r/inc/TRFunctionExport.h b/bindings/r/inc/TRFunctionExport.h index 29f0c403e74cf..93e0fc28f252d 100644 --- a/bindings/r/inc/TRFunctionExport.h +++ b/bindings/r/inc/TRFunctionExport.h @@ -21,6 +21,7 @@ namespace ROOT { namespace R { /** + \class TRFunctionExport This is a class to pass functions from ROOT to R

TRFunctionExport class

@@ -161,7 +162,6 @@ namespace ROOT { */ template TRFunctionExport(T fun) { - // f = new TRInternalFunction(fun); } diff --git a/bindings/r/inc/TRFunctionImport.h b/bindings/r/inc/TRFunctionImport.h index 406dbfe88121b..ff0103225084a 100644 --- a/bindings/r/inc/TRFunctionImport.h +++ b/bindings/r/inc/TRFunctionImport.h @@ -30,6 +30,7 @@ namespace ROOT { namespace R { /** + \class TRFunctionImport This is a class to pass functions from ROOT to R

TRFunctionImport class

diff --git a/bindings/r/inc/TRInterface.h b/bindings/r/inc/TRInterface.h index 28c11834da1b5..cf50f295ef2d3 100644 --- a/bindings/r/inc/TRInterface.h +++ b/bindings/r/inc/TRInterface.h @@ -32,14 +32,15 @@ #include #endif - -namespace ROOT { - namespace R { /** - @defgroup R R Interface for Statistical Computing + @namespace ROOT::R + namespace associated R package for ROOT. + @defgroup R R Interface for Statistical Computing */ - +namespace ROOT { + namespace R { /** +\class TRInterface ROOT R was implemented using the R Project library and the modules Rcpp and @@ -48,7 +49,7 @@ namespace ROOT { http://oproject.org/tiki-index.php?page=ROOT+R+Users+Guide
https://root.cern.ch/drupal/content/how-use-r-root-root-r-interface - @ingroup R + \ingroup R */ @@ -202,6 +203,15 @@ the known function and the fitted function. TString fName; }; private: + /** + The command line arguments are by deafult argc=0 and argv=NULL, + The verbose mode is by default disabled but you can enable it to show procedures information in stdout/stderr \note some time can produce so much noise in the output + \param argc default 0 + \param args default null + \param loadRcpp default true + \param verbose default false + \param interactive default true + */ TRInterface(const int argc = 0, const char *argv[] = NULL, const bool loadRcpp = true, const bool verbose = false, const bool interactive = true); public: ~TRInterface(); diff --git a/bindings/r/inc/TRObject.h b/bindings/r/inc/TRObject.h index d9505d01aad76..edbdf84ce43d9 100644 --- a/bindings/r/inc/TRObject.h +++ b/bindings/r/inc/TRObject.h @@ -68,7 +68,7 @@ namespace ROOT { http://oproject.org/tiki-index.php?page=ROOT+R+Users+Guide
https://root.cern.ch/drupal/content/how-use-r-root-root-r-interface - @ingroup R + @ingroup R */ class TRObject: public TObject { friend SEXP Rcpp::wrap(const TRObject &f); diff --git a/bindings/r/src/TRInterface.cxx b/bindings/r/src/TRInterface.cxx index 7264849703318..21ee2b8a43a45 100644 --- a/bindings/r/src/TRInterface.cxx +++ b/bindings/r/src/TRInterface.cxx @@ -22,10 +22,6 @@ ClassImp(TRInterface) static ROOT::R::TRInterface *gR = NULL; static Bool_t statusEventLoop; -//////////////////////////////////////////////////////////////////////////////// -/// The command line arguments are by deafult argc=0 and argv=NULL, -/// The verbose mode is by default disabled but you can enable it to show procedures information in stdout/stderr - TRInterface::TRInterface(const int argc, const char *argv[], const bool loadRcpp, const bool verbose, const bool interactive): TObject() { if (RInside::instancePtr()) throw std::runtime_error("Can only have one TRInterface instance"); @@ -69,9 +65,7 @@ Int_t TRInterface::Eval(const TString &code, TRObject &ans) return rc; } -//////////////////////////////////////////////////////////////////////////////// -/// Execute R code. - +//______________________________________________________________________________ void TRInterface::Execute(const TString &code) { try{ @@ -114,8 +108,7 @@ void TRInterface::SetVerbose(Bool_t status) fR->setVerbose(status); } -//////////////////////////////////////////////////////////////////////////////// - +//______________________________________________________________________________ TRInterface::Binding TRInterface::operator[](const TString &name) { return Binding(this, name); @@ -148,9 +141,7 @@ void TRInterface::Interactive() } -//////////////////////////////////////////////////////////////////////////////// -///return a pointer to TRInterface. - +//______________________________________________________________________________ TRInterface *TRInterface::InstancePtr() { if (!gR) { @@ -161,26 +152,27 @@ TRInterface *TRInterface::InstancePtr() return gR; } -//////////////////////////////////////////////////////////////////////////////// -///return a reference object of TRInterface. - +//______________________________________________________________________________ TRInterface &TRInterface::Instance() { return *TRInterface::InstancePtr(); } +//______________________________________________________________________________ Bool_t TRInterface::IsInstalled(TString pkg) { TString cmd="is.element('"+pkg+"', installed.packages()[,1])"; return fR->parseEval(cmd.Data()); } +//______________________________________________________________________________ Bool_t TRInterface::Require(TString pkg) { TString cmd="require('"+pkg+"',quiet=TRUE)"; return fR->parseEval(cmd.Data()); } +//______________________________________________________________________________ Bool_t TRInterface::Install(TString pkg,TString repos) { TString cmd="install.packages('"+pkg+"',repos='"+repos+"',dependencies=TRUE)"; @@ -192,9 +184,7 @@ Bool_t TRInterface::Install(TString pkg,TString repos) #undef _POSIX_C_SOURCE #include -//////////////////////////////////////////////////////////////////////////////// -///run the R's eventloop to process graphics events - +//______________________________________________________________________________ void TRInterface::ProcessEventsLoop() { if (!statusEventLoop) { diff --git a/documentation/doxygen/Doxyfile b/documentation/doxygen/Doxyfile index 3a4e19ee2e6a6..8c7482c1bfd3a 100644 --- a/documentation/doxygen/Doxyfile +++ b/documentation/doxygen/Doxyfile @@ -753,8 +753,7 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = ../../bindings/r/ \ - ../../core/base/ \ +INPUT = ../../core/base/ \ ../../core/cont/ \ ../../core/meta/ \ ../../core/metautils/ \ @@ -801,7 +800,8 @@ INPUT = ../../bindings/r/ \ ../../tree \ ../../sql/ \ ../../gui/gui/ \ - ../../gui/fitpanel/ + ../../gui/fitpanel/ \ + ../../bindings/r/ # ../../gui/ged/ \ @@ -934,7 +934,7 @@ EXAMPLE_RECURSIVE = NO # that contain images that are to be included in the documentation (see the # \image command). -IMAGE_PATH = +IMAGE_PATH = ../../bindings/r/doc/users-guide/img/ # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program From ae884ee0588e9b78e31667a7cb90851b28ed4329 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mes Date: Mon, 17 Aug 2015 18:30:42 -0500 Subject: [PATCH 19/21] ROOTR: added default graphics device option in TRInterface and a new constructor for TRFunctionImport --- bindings/r/inc/TRFunctionImport.h | 10 ++++++++++ bindings/r/src/TRFunctionImport.cxx | 6 ++++++ bindings/r/src/TRInterface.cxx | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/bindings/r/inc/TRFunctionImport.h b/bindings/r/inc/TRFunctionImport.h index ff0103225084a..863e0d181c84d 100644 --- a/bindings/r/inc/TRFunctionImport.h +++ b/bindings/r/inc/TRFunctionImport.h @@ -160,6 +160,11 @@ namespace ROOT { \param obj raw R object */ TRFunctionImport(SEXP obj); + /** + TRFunctionImport constructor + \param obj TRObject object + */ + TRFunctionImport(TRObject &obj); ~TRFunctionImport() { @@ -172,6 +177,11 @@ namespace ROOT { #include ClassDef(TRFunctionImport, 0) // }; + + template<> inline TRObject::operator TRFunctionImport() + { + return (SEXP)fObj; + } } } diff --git a/bindings/r/src/TRFunctionImport.cxx b/bindings/r/src/TRFunctionImport.cxx index 1d35bb991de79..f0586ba7d42db 100644 --- a/bindings/r/src/TRFunctionImport.cxx +++ b/bindings/r/src/TRFunctionImport.cxx @@ -41,6 +41,12 @@ TRFunctionImport::TRFunctionImport(const TString& name, const TString& ns) f=new Rcpp::Function(name.Data(),ns.Data()); } +//______________________________________________________________________________ +TRFunctionImport::TRFunctionImport(TRObject &obj):TObject(obj) +{ + f=new Rcpp::Function((SEXP)obj); +} + //______________________________________________________________________________ TRFunctionImport::TRFunctionImport(SEXP obj) { diff --git a/bindings/r/src/TRInterface.cxx b/bindings/r/src/TRInterface.cxx index 21ee2b8a43a45..8482d4fd731f5 100644 --- a/bindings/r/src/TRInterface.cxx +++ b/bindings/r/src/TRInterface.cxx @@ -39,6 +39,15 @@ TRInterface::TRInterface(const int argc, const char *argv[], const bool loadRcpp RComp_retrieveCompsSym = Rf_install(".retrieveCompletions"); rl_attempted_completion_function = R_custom_completion; statusEventLoop = kFALSE; + std::string osname=Eval("Sys.info()['sysname']"); + //only for linux/mac windows is not supported by ROOT yet. + if(osname=="Linux") + { + Execute("options(device='x11')"); + }else{ + Execute("options(device='quartz')"); + } + } TRInterface::~TRInterface() From 8e5205d7c5b88acffca62a70655467b9ec688f13 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mes Date: Sat, 29 Aug 2015 21:29:28 -0500 Subject: [PATCH 20/21] ROOTR: fixed compilation with autotools --- bindings/r/Module.mk | 7 +++++-- configure | 2 +- tutorials/r/rootlogon.C | 6 ------ 3 files changed, 6 insertions(+), 9 deletions(-) delete mode 100644 tutorials/r/rootlogon.C diff --git a/bindings/r/Module.mk b/bindings/r/Module.mk index 47d1b6606af3d..0dc62b8d816fd 100644 --- a/bindings/r/Module.mk +++ b/bindings/r/Module.mk @@ -25,12 +25,15 @@ RDO := $(RDS:.cxx=.o) RDH := $(MODDIRI)/RExports.h \ $(MODDIRI)/TRInterface.h \ - $(MODDIRI)/TRObjectProxy.h \ + $(MODDIRI)/TRInterface_Binding.h \ + $(MODDIRI)/TRObject.h \ $(MODDIRI)/TRDataFrame.h \ + $(MODDIRI)/TRDataFrame__ctors.h \ $(MODDIRI)/TRFunctionImport.h \ + $(MODDIRI)/TRFunctionImport__oprtr.h \ $(MODDIRI)/TRFunctionExport.h \ $(MODDIRI)/TRInternalFunction.h \ - $(MODDIRI)/TRInternalFunction__ctors.h + $(MODDIRI)/TRInternalFunction__ctors.h diff --git a/configure b/configure index f55e8ac2c1485..adae54f036317 100755 --- a/configure +++ b/configure @@ -200,7 +200,7 @@ if test "x$ENABLEALL" = "xyes"; then enable_unuran=yes enable_vc=yes enable_vdt=yes - #enable_r=yes + enable_r=yes fi # Remove old log file diff --git a/tutorials/r/rootlogon.C b/tutorials/r/rootlogon.C deleted file mode 100644 index fe850d7dd0216..0000000000000 --- a/tutorials/r/rootlogon.C +++ /dev/null @@ -1,6 +0,0 @@ -//#include - -void rootlogon(){ -// gSystem->AddIncludePath(RINCLUDEPATH); -// gSystem->AddLinkedLibs(RLINKEDLIBS); -} From 2c366677c3bc3ba950b51a2798ff718f1d0310e3 Mon Sep 17 00:00:00 2001 From: Omar Andres Zapata Mes Date: Sun, 30 Aug 2015 01:42:51 -0500 Subject: [PATCH 21/21] ROOTR: added needed cast operator to SEXP(Raw R object) --- bindings/r/inc/TRDataFrame.h | 12 ++++++++++++ bindings/r/inc/TRObject.h | 8 +++++++- bindings/r/tests/Functions.C | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/bindings/r/inc/TRDataFrame.h b/bindings/r/inc/TRDataFrame.h index 7b0e64a8f2d0d..aebba992d3c9d 100644 --- a/bindings/r/inc/TRDataFrame.h +++ b/bindings/r/inc/TRDataFrame.h @@ -371,16 +371,28 @@ namespace ROOT { df = obj.df; return *this; } + TRDataFrame &operator=(TRDataFrame obj) { df = obj.df; return *this; } + TRDataFrame &operator=(SEXP obj) { df = Rcpp::as(obj); return *this; } + + operator SEXP() + { + return df; + } + + operator SEXP() const + { + return df; + } /** Method to get the number of colunms diff --git a/bindings/r/inc/TRObject.h b/bindings/r/inc/TRObject.h index edbdf84ce43d9..aa806be0a36e3 100644 --- a/bindings/r/inc/TRObject.h +++ b/bindings/r/inc/TRObject.h @@ -167,11 +167,17 @@ namespace ROOT { { return ::Rcpp::as(obj); } + operator SEXP() { return fObj; } - + + operator SEXP() const + { + return fObj; + } + operator Rcpp::RObject() { return fObj; diff --git a/bindings/r/tests/Functions.C b/bindings/r/tests/Functions.C index 9330c8b974e2f..a23b316d20cee 100644 --- a/bindings/r/tests/Functions.C +++ b/bindings/r/tests/Functions.C @@ -77,6 +77,7 @@ void Functions(TString type = "Import") ROOT::R::TRFunctionImport x11("x11"); ROOT::R::TRFunctionImport read("read.csv"); ROOT::R::TRFunctionImport head("head"); + ROOT::R::TRFunctionImport aslist("as.list"); ROOT::R::TRFunctionImport options("options"); options(ROOT::R::Label["device"]="x11"); @@ -101,8 +102,8 @@ void Functions(TString type = "Import") ROOT::R::TRDataFrame obj=read("training.csv"); // ROOT::R::TRDataFrame df(obj.As()); + print(head(Rcpp::wrap(obj))); print(head(obj)); -// print(vector); x11(); plot(sin,0,6,ROOT::R::Label["type"]="s"); x11();