From 954498a40afb55e28c2fe1ed09bad56648fdb6f7 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Tue, 2 Jun 2026 17:03:49 +0200 Subject: [PATCH] Remove R programming language interface that was deprecated in 6.40 Remove R programming language interface that was deprecated in 6.40 and scheduled for removal in 6.42. --- .../buildconfig/alma10-benchmark.txt | 1 - .../buildconfig/alma10-clang_ninja.txt | 1 - .../root-ci-config/buildconfig/alma10.txt | 1 - .../root-ci-config/buildconfig/global.txt | 2 - .../root-ci-config/buildconfig/mac-beta.txt | 1 - .../root-ci-config/buildconfig/mac14.txt | 1 - .../root-ci-config/buildconfig/mac15.txt | 1 - .../root-ci-config/buildconfig/mac26.txt | 1 - .../buildconfig/opensuse16-march_native.txt | 1 - .../root-ci-config/buildconfig/ubuntu22.txt | 1 - .../root-ci-config/buildconfig/windows10.txt | 1 - README/ReleaseNotes/v642/index.md | 1 + bindings/CMakeLists.txt | 4 - bindings/r/CMakeLists.txt | 50 - bindings/r/TODO | 7 - .../r/doc/users-guide/ROOTR_Users_Guide.md | 853 ---------------- .../r/doc/users-guide/img/interpolation.png | Bin 42130 -> 0 bytes bindings/r/doc/users-guide/img/logo.jpeg | Bin 69018 -> 0 bytes .../r/doc/users-guide/img/minimization.jpeg | Bin 50282 -> 0 bytes bindings/r/doc/users-guide/img/simplefit.gif | Bin 12814 -> 0 bytes bindings/r/inc/LinkDef.h | 32 - bindings/r/inc/RExports.h | 195 ---- bindings/r/inc/TRDataFrame.h | 443 --------- bindings/r/inc/TRDataFrame__ctors.h | 156 --- bindings/r/inc/TRFunctionExport.h | 189 ---- bindings/r/inc/TRFunctionImport.h | 179 ---- bindings/r/inc/TRFunctionImport__oprtr.h | 133 --- bindings/r/inc/TRInterface.h | 328 ------ bindings/r/inc/TRInterface_Binding.h | 940 ------------------ bindings/r/inc/TRInternalFunction.h | 64 -- bindings/r/inc/TRInternalFunction__ctors.h | 607 ----------- bindings/r/inc/TRObject.h | 200 ---- bindings/r/src/RExports.cxx | 118 --- bindings/r/src/TRCompletion.cxx | 94 -- bindings/r/src/TRCompletion.h | 49 - bindings/r/src/TRDataFrame.cxx | 31 - bindings/r/src/TRFunctionExport.cxx | 26 - bindings/r/src/TRFunctionImport.cxx | 51 - bindings/r/src/TRInterface.cxx | 300 ------ bindings/r/src/TRObject.cxx | 27 - bindings/r/tests/Binding.C | 149 --- bindings/r/tests/Class.C | 38 - bindings/r/tests/DataFrame.C | 115 --- bindings/r/tests/Exception.C | 22 - bindings/r/tests/ExpClass.C | 52 - bindings/r/tests/FunModule.C | 22 - bindings/r/tests/Functions.C | 121 --- bindings/r/tests/Functor.C | 35 - bindings/r/tests/Object.C | 30 - bindings/r/tests/Proxy.C | 65 -- bindings/r/tests/ROOTR.C | 38 - bindings/r/tests/TRF1.R | 13 - cmake/modules/RootBuildOptions.cmake | 6 +- cmake/modules/RootConfiguration.cmake | 5 - cmake/modules/SearchInstalledSoftware.cmake | 26 +- cmake/unix/makepchinput.py | 3 +- config/RConfigure.in | 1 - math/CMakeLists.txt | 4 - math/rtools/CMakeLists.txt | 27 - math/rtools/inc/LinkDef.h | 8 - math/rtools/inc/Math/RMinimizer.h | 89 -- math/rtools/src/RMinimizer.cxx | 182 ---- tmva/CMakeLists.txt | 5 - tmva/rmva/CMakeLists.txt | 32 - tmva/rmva/inc/LinkDef.h | 19 - tmva/rmva/inc/TMVA/MethodC50.h | 117 --- tmva/rmva/inc/TMVA/MethodRSNNS.h | 123 --- tmva/rmva/inc/TMVA/MethodRSVM.h | 138 --- tmva/rmva/inc/TMVA/MethodRXGB.h | 112 --- tmva/rmva/inc/TMVA/RMethodBase.h | 87 -- tmva/rmva/src/MethodC50.cxx | 340 ------- tmva/rmva/src/MethodRSNNS.cxx | 365 ------- tmva/rmva/src/MethodRSVM.cxx | 388 -------- tmva/rmva/src/MethodRXGB.cxx | 282 ------ tmva/rmva/src/RMethodBase.cxx | 111 --- tmva/rmva/test/Classification.C | 109 -- tutorials/CMakeLists.txt | 5 - tutorials/math/r/DataFrame.C | 74 -- tutorials/math/r/Function.C | 57 -- tutorials/math/r/Functor.C | 86 -- tutorials/math/r/GlobalMinimization.C | 109 -- tutorials/math/r/Integration.C | 59 -- tutorials/math/r/Interpolation.C | 75 -- tutorials/math/r/Minimization.C | 71 -- tutorials/math/r/SimpleFitting.C | 84 -- tutorials/math/r/example.C | 67 -- 86 files changed, 5 insertions(+), 9050 deletions(-) delete mode 100644 bindings/r/CMakeLists.txt delete mode 100644 bindings/r/TODO delete mode 100644 bindings/r/doc/users-guide/ROOTR_Users_Guide.md delete mode 100644 bindings/r/doc/users-guide/img/interpolation.png delete mode 100644 bindings/r/doc/users-guide/img/logo.jpeg delete mode 100644 bindings/r/doc/users-guide/img/minimization.jpeg delete mode 100644 bindings/r/doc/users-guide/img/simplefit.gif delete mode 100644 bindings/r/inc/LinkDef.h delete mode 100644 bindings/r/inc/RExports.h delete mode 100644 bindings/r/inc/TRDataFrame.h delete mode 100644 bindings/r/inc/TRDataFrame__ctors.h delete mode 100644 bindings/r/inc/TRFunctionExport.h delete mode 100644 bindings/r/inc/TRFunctionImport.h delete mode 100644 bindings/r/inc/TRFunctionImport__oprtr.h delete mode 100644 bindings/r/inc/TRInterface.h delete mode 100644 bindings/r/inc/TRInterface_Binding.h delete mode 100644 bindings/r/inc/TRInternalFunction.h delete mode 100644 bindings/r/inc/TRInternalFunction__ctors.h delete mode 100644 bindings/r/inc/TRObject.h delete mode 100644 bindings/r/src/RExports.cxx delete mode 100644 bindings/r/src/TRCompletion.cxx delete mode 100644 bindings/r/src/TRCompletion.h delete mode 100644 bindings/r/src/TRDataFrame.cxx delete mode 100644 bindings/r/src/TRFunctionExport.cxx delete mode 100644 bindings/r/src/TRFunctionImport.cxx delete mode 100644 bindings/r/src/TRInterface.cxx delete mode 100644 bindings/r/src/TRObject.cxx delete mode 100644 bindings/r/tests/Binding.C delete mode 100644 bindings/r/tests/Class.C delete mode 100644 bindings/r/tests/DataFrame.C delete mode 100644 bindings/r/tests/Exception.C delete mode 100644 bindings/r/tests/ExpClass.C delete mode 100644 bindings/r/tests/FunModule.C delete mode 100644 bindings/r/tests/Functions.C delete mode 100644 bindings/r/tests/Functor.C delete mode 100644 bindings/r/tests/Object.C delete mode 100644 bindings/r/tests/Proxy.C delete mode 100644 bindings/r/tests/ROOTR.C delete mode 100644 bindings/r/tests/TRF1.R delete mode 100644 math/rtools/CMakeLists.txt delete mode 100644 math/rtools/inc/LinkDef.h delete mode 100644 math/rtools/inc/Math/RMinimizer.h delete mode 100644 math/rtools/src/RMinimizer.cxx delete mode 100644 tmva/rmva/CMakeLists.txt delete mode 100644 tmva/rmva/inc/LinkDef.h delete mode 100644 tmva/rmva/inc/TMVA/MethodC50.h delete mode 100644 tmva/rmva/inc/TMVA/MethodRSNNS.h delete mode 100644 tmva/rmva/inc/TMVA/MethodRSVM.h delete mode 100644 tmva/rmva/inc/TMVA/MethodRXGB.h delete mode 100644 tmva/rmva/inc/TMVA/RMethodBase.h delete mode 100644 tmva/rmva/src/MethodC50.cxx delete mode 100644 tmva/rmva/src/MethodRSNNS.cxx delete mode 100644 tmva/rmva/src/MethodRSVM.cxx delete mode 100644 tmva/rmva/src/MethodRXGB.cxx delete mode 100644 tmva/rmva/src/RMethodBase.cxx delete mode 100644 tmva/rmva/test/Classification.C delete mode 100644 tutorials/math/r/DataFrame.C delete mode 100644 tutorials/math/r/Function.C delete mode 100644 tutorials/math/r/Functor.C delete mode 100644 tutorials/math/r/GlobalMinimization.C delete mode 100644 tutorials/math/r/Integration.C delete mode 100644 tutorials/math/r/Interpolation.C delete mode 100644 tutorials/math/r/Minimization.C delete mode 100644 tutorials/math/r/SimpleFitting.C delete mode 100644 tutorials/math/r/example.C diff --git a/.github/workflows/root-ci-config/buildconfig/alma10-benchmark.txt b/.github/workflows/root-ci-config/buildconfig/alma10-benchmark.txt index ce7742559e68f..5033c803b0c0a 100644 --- a/.github/workflows/root-ci-config/buildconfig/alma10-benchmark.txt +++ b/.github/workflows/root-ci-config/buildconfig/alma10-benchmark.txt @@ -1,5 +1,4 @@ CMAKE_CXX_STANDARD=20 builtin_vdt=ON pythia8=ON -r=OFF rootbench=ON diff --git a/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt b/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt index 560ed0afb6ee0..a970b4b2e1d25 100644 --- a/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt +++ b/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt @@ -20,5 +20,4 @@ builtin_xxhash=ON builtin_zlib=ON builtin_zstd=ON pythia8=ON -r=OFF soversion=ON diff --git a/.github/workflows/root-ci-config/buildconfig/alma10.txt b/.github/workflows/root-ci-config/buildconfig/alma10.txt index f265d40f10e5a..30497871ebde5 100644 --- a/.github/workflows/root-ci-config/buildconfig/alma10.txt +++ b/.github/workflows/root-ci-config/buildconfig/alma10.txt @@ -1,3 +1,2 @@ builtin_vdt=ON pythia8=ON -r=OFF diff --git a/.github/workflows/root-ci-config/buildconfig/global.txt b/.github/workflows/root-ci-config/buildconfig/global.txt index 91b34924b26f0..4e598d6afa5ed 100644 --- a/.github/workflows/root-ci-config/buildconfig/global.txt +++ b/.github/workflows/root-ci-config/buildconfig/global.txt @@ -63,7 +63,6 @@ opengl=ON pyroot=ON pythia8=OFF qt6web=OFF -r=ON roofit=ON roofit_multiprocess=OFF root7=ON @@ -83,7 +82,6 @@ tmva-cpu=ON tmva-gpu=OFF tmva-cudnn=OFF tmva-pymva=OFF -tmva-rmva=OFF tmva-sofie=ON tmva=ON unfold=ON diff --git a/.github/workflows/root-ci-config/buildconfig/mac-beta.txt b/.github/workflows/root-ci-config/buildconfig/mac-beta.txt index 8fa352a9bf042..9b29374d539eb 100644 --- a/.github/workflows/root-ci-config/buildconfig/mac-beta.txt +++ b/.github/workflows/root-ci-config/buildconfig/mac-beta.txt @@ -22,6 +22,5 @@ check_connection=ON cocoa=ON davix=OFF minuit2_omp=OFF -r=OFF tmva-sofie=OFF x11=OFF diff --git a/.github/workflows/root-ci-config/buildconfig/mac14.txt b/.github/workflows/root-ci-config/buildconfig/mac14.txt index c5bfe2f8f8702..1a203c9336cc5 100644 --- a/.github/workflows/root-ci-config/buildconfig/mac14.txt +++ b/.github/workflows/root-ci-config/buildconfig/mac14.txt @@ -25,7 +25,6 @@ cocoa=ON davix=OFF fortran=OFF minuit2_omp=OFF -r=OFF test_distrdf_dask=OFF test_distrdf_pyspark=OFF x11=OFF diff --git a/.github/workflows/root-ci-config/buildconfig/mac15.txt b/.github/workflows/root-ci-config/buildconfig/mac15.txt index 656b40f6eb6f5..d16d25feaf528 100644 --- a/.github/workflows/root-ci-config/buildconfig/mac15.txt +++ b/.github/workflows/root-ci-config/buildconfig/mac15.txt @@ -20,5 +20,4 @@ builtin_zstd=ON cocoa=ON davix=OFF minuit2_omp=OFF -r=OFF x11=OFF diff --git a/.github/workflows/root-ci-config/buildconfig/mac26.txt b/.github/workflows/root-ci-config/buildconfig/mac26.txt index 8fa352a9bf042..9b29374d539eb 100644 --- a/.github/workflows/root-ci-config/buildconfig/mac26.txt +++ b/.github/workflows/root-ci-config/buildconfig/mac26.txt @@ -22,6 +22,5 @@ check_connection=ON cocoa=ON davix=OFF minuit2_omp=OFF -r=OFF tmva-sofie=OFF x11=OFF diff --git a/.github/workflows/root-ci-config/buildconfig/opensuse16-march_native.txt b/.github/workflows/root-ci-config/buildconfig/opensuse16-march_native.txt index 92db1d48e403f..84a16099e3d59 100644 --- a/.github/workflows/root-ci-config/buildconfig/opensuse16-march_native.txt +++ b/.github/workflows/root-ci-config/buildconfig/opensuse16-march_native.txt @@ -11,4 +11,3 @@ test_distrdf_pyspark=OFF tmva-pymva=ON tmva-sofie=ON pythia8=OFF -r=OFF diff --git a/.github/workflows/root-ci-config/buildconfig/ubuntu22.txt b/.github/workflows/root-ci-config/buildconfig/ubuntu22.txt index e41a034320598..e0efc61fe89f0 100644 --- a/.github/workflows/root-ci-config/buildconfig/ubuntu22.txt +++ b/.github/workflows/root-ci-config/buildconfig/ubuntu22.txt @@ -1,5 +1,4 @@ builtin_unuran=ON builtin_vdt=ON -r=ON test_distrdf_dask=OFF test_distrdf_pyspark=OFF diff --git a/.github/workflows/root-ci-config/buildconfig/windows10.txt b/.github/workflows/root-ci-config/buildconfig/windows10.txt index 5eaa076ea38a4..f0e25365d4838 100644 --- a/.github/workflows/root-ci-config/buildconfig/windows10.txt +++ b/.github/workflows/root-ci-config/buildconfig/windows10.txt @@ -25,7 +25,6 @@ minuit2_mpi=OFF minuit2_omp=OFF pyroot2=OFF pyroot3=ON -r=OFF runtime_cxxmodules=OFF ssl=OFF test_distrdf_dask=OFF diff --git a/README/ReleaseNotes/v642/index.md b/README/ReleaseNotes/v642/index.md index c83e470f61933..d04da9e29395c 100644 --- a/README/ReleaseNotes/v642/index.md +++ b/README/ReleaseNotes/v642/index.md @@ -45,6 +45,7 @@ The following people have contributed to this new version: * The `builtin_zeromq` and `builtin_cppzmq` build options that were deprecated in ROOT 6.40 are now removed. * The ROOT **auth** package together with `TVirtualAuth` and `TROOT::GetListOfSecContexts()`, and the **authenticated sockets** (`TSocket::CreateAuthSocket()`) feature are now removed following deprecation in ROOT 6.40. * The `TSSLSocket` class is now removed following deprecation in ROOT 6.40. +* The bindings to the R programming language that are enabled with the `r=ON` or `tmva-rmva=ON` build options (`TRInterface`, RMVA, and friends) are removed, following deprecation in ROOT 6.40. Their maintenance is no longer justified, given the broader adoption of the scientific Python ecosystem. Users who still rely on R from C++ are encouraged to call R directly via https://cran.r-project.org/package=RInside, which is what the ROOT bindings were using internally. ## Python Interface diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index c6c76642fa61c..2ce67833d2adc 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -19,7 +19,3 @@ endif() if(tpython) add_subdirectory(tpython) endif() - -if(r) - add_subdirectory(r) -endif() diff --git a/bindings/r/CMakeLists.txt b/bindings/r/CMakeLists.txt deleted file mode 100644 index f899a8987446d..0000000000000 --- a/bindings/r/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. -# All rights reserved. -# -# For the licensing terms see $ROOTSYS/LICENSE. -# For the list of contributors see $ROOTSYS/README/CREDITS. - -############################################################################ -# CMakeLists.txt file for building ROOT R package -############################################################################ - -ROOT_STANDARD_LIBRARY_PACKAGE(RInterface - HEADERS - RExports.h - TRDataFrame.h - TRFunctionExport.h - TRFunctionImport.h - TRInterface.h - TRInternalFunction.h - TRObject.h - SOURCES - src/RExports.cxx - src/TRCompletion.cxx - src/TRDataFrame.cxx - src/TRFunctionExport.cxx - src/TRFunctionImport.cxx - src/TRInterface.cxx - src/TRObject.cxx - DEPENDENCIES - Core - Matrix - RIO - Thread - NO_CXXMODULE -) - -ROOT_ADD_CXX_FLAG(_R_FLAGS -Wno-cast-function-type) -ROOT_ADD_CXX_FLAG(_R_FLAGS -Wno-overloaded-virtual) -if(x11) - ROOT_ADD_CXX_FLAG(_R_FLAGS -DHAS_X11) -endif() - -separate_arguments(_R_FLAGS) - -target_compile_options(RInterface PUBLIC ${_R_FLAGS}) -target_include_directories(RInterface SYSTEM BEFORE PUBLIC ${R_INCLUDE_DIRS}) -if(x11) - target_link_libraries(RInterface PUBLIC ${R_LIBRARIES} ${X11_LIBRARIES} readline) -else() - target_link_libraries(RInterface PUBLIC ${R_LIBRARIES} readline) -endif() diff --git a/bindings/r/TODO b/bindings/r/TODO deleted file mode 100644 index f63546f1329df..0000000000000 --- a/bindings/r/TODO +++ /dev/null @@ -1,7 +0,0 @@ -TRDataFrame -- overload [][] -- method to remove col -- method to get row -- methods to get sub dataframes -- implement error handling (exceptions are terminating the application) -- Users guide section diff --git a/bindings/r/doc/users-guide/ROOTR_Users_Guide.md b/bindings/r/doc/users-guide/ROOTR_Users_Guide.md deleted file mode 100644 index 76690dd432049..0000000000000 --- a/bindings/r/doc/users-guide/ROOTR_Users_Guide.md +++ /dev/null @@ -1,853 +0,0 @@ -# ROOTR Users Guide - -## DESCRIPTION -ROOT R is an interface in ROOT to call R functions using an R C++ interface (Rcpp, see http://dirk.eddelbuettel.com/code/rcpp.html). -This interface opens the possibility in ROOT to use the very large set of mathematical and statistical tools provided by R. -With ROOTR you can perform a conversion from ROOT's C++ objects to R's objects, transform the returned R objects into ROOT's C++ objects, then -the R functionality can be used directly for statistical studies in ROOT. - -## ROOTR BASICS -ROOTR creates a working environment to execute R coding called from `C++`. It allows to translate some datatypes from `C++` to R -inside the R environment and vice versa in an easy way to get the most from both R and ROOT. -To ease the sending and receiving of data in both environments, I overloaded the operators `<<`,`>>` and `[]` -which make look the job as a flow of data between environments, we will see more of that later. -With this tool you ca use any library or R package wich allows you to access a big amount of benefits to make statistical analysis. -ROOTR also has a R events processing system, which allows to use the R graphical system from `C++`. - -## INSTALLATION -To install ROOTR please read first. - -- [https://root.cern.ch/building-root](https://root.cern.ch/building-root) -- [https://root.cern.ch/build-prerequisites](https://root.cern.ch/build-prerequisites) - - -### COMPILING ROOTR ON MAC WITH CMAKE: -**NOTE:** Mac OSX Yosemite last xcode and without macports - - -**Prerequisites** - -- xcode -- [xquartz](http://xquartz.macosforge.org/) -- [R last version](https://www.r-project.org) -- [cmake](https://cmake.org/download/) - -To compile with cmake added into ~/.profile - -~~~{.sh} -export PATH=$PATH:/Applications/CMake.app/Contents/bin/ -~~~ -and - -~~~{.sh} -source ~/.profile -~~~ - -Install needed R packages, open R and in the prompt type - -~~~{.sh} -install.packages(c('Rcpp','RInside')) -~~~ -select a mirror and install. - -Install the next additional packages for R TMVA interface - -~~~{.sh} -install.packages(c('C50','RSNNS','e1071','xgboost')) -~~~ - - -Download code from git repo - -~~~{.sh} -git clone http://root.cern.ch/git/root.git -~~~ - -To compile ROOTR lets to create a compilation directory and to activate it use cmake -Dr=ON .. - -~~~{.sh} -mkdir compile -cd compile -cmake -Dr=ON .. -make -j 5 -~~~ - -### Compiling ROOTR on Gnu/Linux with CMake: -**NOTE:** Tested on Gnu/Linux Debian Jessie with gcc 4.9 - -**Prerequisities** -install -(For debian-based distros) - -~~~{.sh} -apt-get install r-base r-base-dev -~~~ -Install needed R packages, open R and in the prompt type - -~~~{.sh} -install.packages(c('Rcpp','RInside')) -~~~ -select a mirror and install. - -Install the next additional packages for R TMVA interface - -~~~{.sh} -install.packages(c('C50','RSNNS','e1071','xgboost')) -~~~ - -Download code from git repo - -~~~{.sh} -git clone http://root.cern.ch/git/root.git -~~~ - -To compile ROOTR lets to create a compilation directory and to activate it use cmake -Dr=ON .. - -~~~{.sh} -mkdir compile -cd compile -cmake -Dr=ON .. -make -j 5 -~~~ - -## How does it work ? -There is a class called TRInterface which is located at the header TRInterface.h and uses the namespace `ROOT::R`, it is in charge -of making calls to R to give and obtain data. This class has a series of overcharged operators which ease the passing and obtaining of data -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. - -~~~{.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). - -~~~{.cxx} -#include - -//creating an instance -ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -//executing simple r commands with the operator << -r<<"print('hello ROOTR')"; -r<<"vec=c(1,2,3)"<<"print(vec)"; - -//executing R's code using the method Execute that doesn't return anything -r.Execute("print('hello ROOTR')"); - -//We execute the code using the method Eval which returns an instance of TRObjectProxy -//which can be converted to a ROOTR supported classes -std::vector v=r.Eval("c(1,2,3)"); -std::cout< vd(3); - -//obtaining variables from R environment using the operators [] and >> -r["seq(0,1,0.5)"]>>vd; -std::cout< 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 -You can pass functions from ROOT to R using the operators `<<` and `=` or using the class TRFunction, but the arguments and datatypes of the return value cannot be pointers. They must be ROOTR supported datatypes. -So instead of using `*Double_t` you must use `std::vector` and instead of `*Char_t` use TString or `std::string`. - -For this example we need to create a macro, so save it as fun.C - -~~~{.cxx} -#include -#include - -Double_t myfun(Double_t x) -{ - return 2*cos(x); -} - -Double_t myfun2(std::vector x) //use std::vector instead Double_t* -{ - return x[1]*cos(x[0]); -} - -void fun() -{ -ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -r["dilog"]< - -Double_t myfun(Double_t x) -{ - return 2*cos(x); -} - -Int_t myfun(Int_t x) -{ - return x; -} - -void fun() -{ -ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -r["myfund"]<<(Double_t (*)(Double_t))myfun; -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 -`ROOT::R::class_<>` -The `ROOTR_EXPOSED_CLASS(Class)` macro allows you to expose the class as a new datatype of R, but it has to be alongside -the `ROOTR_MODULE(Module)` macro which allows you to create an internal R module and make the class wrapping -To do this you must use inside the `ROOTR_MODULE` braces the class `ROOT::R::class_<>` and specify -each constructor, attribute or method that the class to export has. -Then the macrodefinition `LOAD_ROOTR_MODULE(Module)` can load the module and the class in R's environment. -You can find a more clear instruction by looking at a example below in Functor section. - -##DataFrames -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 - -~~~{.cxx} -//////////////////////// -//creating variables// -//////////////////////// -TVectorD v1(3); -std::vector v2(3); -std::array v3{ {1,2,3} }; -std::list names; - -////////////////////// -//assigning values// -////////////////////// -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(); -~~~ -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. - -~~~{.cxx} -///////////////////////////////////////////////// -//creating dataframe object with its labels// -///////////////////////////////////////////////// - -ROOT::R::TRDataFrame df1(ROOT::R::Label["var1"]=v1,ROOT::R::Label["var2"]=v2,ROOT::R::Label["var3"]=v3,ROOT::R::Label["strings"]=names); - -////////////////////////////////////////////// -//Passing dataframe to R's environment// -////////////////////////////////////////////// - -r["df1"]<>v4; -//adding new column to df1 with name var4 -df1["var4"]=v4; -//updating df1 in R's environment -r["df1"]<>df2; - -TVectorD v(3); -df2["v1"]>>v; -v.Print(); - -df2["v2"]>>v; -v.Print(); -~~~ - -Output - -~~~{.sh} -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 -~~~ - -~~~{.cxx} -/////////////////////////////////////////// -//Working with columns between dataframes// -/////////////////////////////////////////// - -df2["v3"]<>df1["var1"]; -//updating df1 in R's environment -r["df1"]< -root [1] ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -root [2] r.Interactive() -[r]:a=seq -seq seq_along seq.Date seq.default seq.int seq_len seq.POSIXt sequence -[r]:a=seq(1,5,0.5) -[r]:.q -root [3] TVectorD v=r.ParseEval("a"); -root [4] v.Print() - -Vector (9) is as follows - - | 1 | ------------------- - 0 |1 - 1 |1.5 - 2 |2 - 3 |2.5 - 4 |3 - 5 |3.5 - 6 |4 - 7 |4.5 - 8 |5 - -root [4] -~~~ - -## Examples -The examples can also be found in `$ROOTSYS/tutorials/r` - -## Creating a Functor -A functor is a class which wraps a function, very useful when states and properties -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. - -~~~{.cxx} -#include -#include - -typedef Double_t (*Function)(Double_t); - -//Functor class with the function inside -class MyFunctor{ -public: - MyFunctor(){ - status=false; - f=TMath::BesselY1; - } - void setFunction(Function fun) - { - f=fun; - status=true; - } - Bool_t getStatus(){return status;} - Double_t doEval(Double_t x) { - return f(x); - } -private: - Function f; - Bool_t status; -}; -//this macro exposes the class into R's environment -// and lets you pass objects directly. -ROOTR_EXPOSED_CLASS(MyFunctor) - -//Macro to create a module -ROOTR_MODULE(MyFunctorModule) { - ROOT::R::class_( "MyFunctor" ) - //creating a default constructor - .constructor() - //adding the method doEval to evaluate the internal function - .method( "doEval", &MyFunctor::doEval ) - .method( "getStatus", &MyFunctor::getStatus) - ; -} - -void Functor() -{ - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - //////////////////////////////////////////////////////////// - //Creating a functor with default function TMath::BesselY1// - // and status false from R's environment // - //////////////////////////////////////////////////////////// - //Loading module into R's environment - r["MyFunctorModule"]<SetGrid(); - - // draw a frame to define the range - TMultiGraph *mg = new TMultiGraph(); - - // create the first graph (points with gaussian noise) - const Int_t n = 24; - Double_t x1[n] ; - Double_t y1[n] ; - //Generate the points along a X^3 with noise - TRandom rg; - rg.SetSeed(520); - for (Int_t i = 0; i < n; i++) { - x1[i] = rg.Uniform(0, 1); - y1[i] = TMath::Power(x1[i], 3) + rg.Gaus() * 0.06; - } - - TGraph *gr1 = new TGraph(n,x1,y1); - gr1->SetMarkerColor(kBlue); - gr1->SetMarkerStyle(8); - gr1->SetMarkerSize(1); - mg->Add(gr1); - - // create the 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 data to Rfot 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; -} -~~~ -In the first image you can see the blue dots which 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. - -\image html R_image1.png - -## Global Minimization in R using the package DEoptim -DEoptim is a R package for Differential Evolution Minimization that lets you do global -Minimization. -To install this package you just need to run: - -~~~{.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. - -~~~{.cxx} -#include -#include -#include -#include -//In the next function the *double pointer should be changed by a TVectorD datatype, -//because the pointer has no meaning in the R environment. -//This is a generalization of the RosenBrock function, with the min xi=1 and i>0. -Double_t GenRosenBrock(const TVectorD xx ) -{ - int length=xx.GetNoElements(); - - Double_t result=0; - for(int i=0;i<(length-1);i++) - { - result+=pow(1-xx[i],2)+100*pow(xx[i+1]-pow(xx[i],2),2); - } - return result; -} - -//the min xi=0 i>0 -Double_t Rastrigin(const TVectorD xx) -{ - int length=xx.GetNoElements(); - Double_t result=10*length; - for(int i=0;i -#include -#include - -void Interpolation() -{ - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -//Creating points -TRandom rg; -std::vector x(10),y(10); -for(int i=0;i<10;i++) -{ - x[i]=i; - y[i]=rg.Gaus(); -} - -r["x"]=x; -r["y"]=y; - - -r<<"dev.new()";//Required to activate new window for plotting -//Plot parameter. Plotting using two rows and one column -r<<"par(mfrow = c(2,1))"; - -//plotting the points -r<<"plot(x, y, main = 'approx(.) and approxfun(.)')"; - -//The function "approx" returns a list with components x and y, -//containing n coordinates which interpolate the given data points according to the method (and rule) desired. -r<<"points(approx(x, y), col = 2, pch = '*')"; -r<<"points(approx(x, y, method = 'constant'), col = 4, pch = '*')"; - - -//The function "approxfun" returns a function performing (linear or constant) -//interpolation of the given data. -//For a given set of x values, this function will return the corresponding interpolated values. -r<<"f <- approxfun(x, y)"; - -r<<"curve(f(x), 0, 11, col = 'green2')"; -r<<"points(x, y)"; - - -//using approxfun with const method -r<<"fc <- approxfun(x, y, method = 'const')"; -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: -\image html R_image3.png - -## Integration (Passing vectorized function to R) -Numerical integration using R passing the function from ROOT - -~~~{.cxx} -#include -#include -#include -#include - -//To integrate using R the function must be vectorized -//The idea is just to receive a vector like an argument,to evaluate -//every element saving the result in another vector -//and return the resultant vector. -std::vector BreitWignerVectorized(std::vector xx) -{ - std::vector result(xx.size()); - for(Int_t i=0;i - - -//Some useful typedefs -typedef std::vector TVectorString; - -namespace ROOT { - namespace R { - class TRFunctionExport; - class TRFunctionImport; - class TRDataFrame; - class TRObject; - } -} - -namespace Rcpp { - -//TString - template<> inline SEXP wrap(const TString &s) - { - return wrap(std::string(s.Data())); - } - template<> inline TString as(SEXP s) - { - return TString(::Rcpp::as(s).c_str()); - } - -//TVectorT - template<> SEXP wrap(const TVectorT &v); - template<> TVectorT as(SEXP v); - - template<> SEXP wrap(const TVectorT &v); - template<> TVectorT as(SEXP v); - -//TMatrixT - template<> SEXP wrap(const TMatrixT &m); - template<> TMatrixT as(SEXP) ; - template<> SEXP wrap(const TMatrixT &m); - template<> TMatrixT as(SEXP) ; - -//TRDataFrame - template<> SEXP wrap(const ROOT::R::TRDataFrame &o); - template<> ROOT::R::TRDataFrame 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); - template<> ROOT::R::TRFunctionImport as(SEXP) ; - - template std::array as(SEXP &obj) - { - std::vector v = Rcpp::as >(obj); - std::array a; - std::copy(v.begin(), v.end(), a.begin()); - return a; - } - - namespace traits { - template - class Exporter > { - public: - Exporter(SEXP x) - { - t = Rcpp::as(x); - } - std::array get() - { - return t; - } - private: - std::array t; - } ; - } -} - -#include//this headers should be called after templates definitions -#undef HAVE_UINTPTR_T -#include - -#ifdef Free -// see https://sft.its.cern.ch/jira/browse/ROOT-9258 -# undef Free -#endif - -// restore warning level of before -#if defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - -namespace ROOT { - namespace R { - //reference to internal ROOTR's Module that call ROOT's classes in R - extern VARIABLE_IS_NOT_USED SEXP ModuleSymRef; - template class class_: public Rcpp::class_ { - public: - class_(const Char_t *name_, const Char_t *doc = 0) : Rcpp::class_(name_, doc) {} - }; - - //________________________________________________________________________________________________________ - template - void function(const Char_t *name_, T fun, const Char_t *docstring = 0) - { - //template function required to create modules using the macro ROOTR_MODULE - Rcpp::function(name_, fun, docstring); - } - - extern const Rcpp::internal::NamedPlaceHolder &Label; - } -} - - -//macros redifined to be accord with the namespace -#define ROOTR_MODULE RCPP_MODULE -#define ROOTR_EXPOSED_CLASS RCPP_EXPOSED_CLASS - -//modified definiton to support ROOTR namespace -#define ROOTR_EXPOSED_CLASS_INTERNAL(CLASS)\ - namespace ROOT{ \ - namespace R{ \ - class CLASS; \ - }} \ - RCPP_EXPOSED_CLASS_NODECL(ROOT::R::CLASS) - - - -//modified macro for ROOTR global Module Object Symbol Reference ROOT::R::ModuleSymRef -#define LOAD_ROOTR_MODULE(NAME) Rf_eval( Rf_lang2( ( ROOT::R::ModuleSymRef == NULL ? ROOT::R::ModuleSymRef = Rf_install("Module") : ROOT::R::ModuleSymRef ), _rcpp_module_boot_##NAME() ), R_GlobalEnv ) -#endif diff --git a/bindings/r/inc/TRDataFrame.h b/bindings/r/inc/TRDataFrame.h deleted file mode 100644 index 0ce1e5a1af492..0000000000000 --- a/bindings/r/inc/TRDataFrame.h +++ /dev/null @@ -1,443 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata Omar.Zapata@cern.ch 30/05/2015 - - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#ifndef ROOT_R_TRDataFrame -#define ROOT_R_TRDataFrame - -#include - -#include - -#include - - -namespace ROOT { - namespace R { - - /** - \class TRDataFrame - - This is a 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"]<Users Guide - https://oproject.org/pages/ROOT R Users Guide
- */ - - - 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) - { - Int_t size = fDf.size(), i = 0; - Rcpp::CharacterVector names = fDf.attr("names"); - Bool_t found = false; - while (i < size) { - if (names[i] == fName.Data()) { - found = true; - break; - } - i++; - } - if (found) fDf[fName.Data()] = var; - else { - 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 < size; i++) { - nDf[i] = fDf[i] ; - nnames[i] = names[i]; - } - 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 ; - fDf = nDf; - } - } - return *this; - } - /** - method for operator assignation of Binding class - \param obj other Binding object - */ - Binding operator=(Binding obj) - { - Int_t size = fDf.size(), i = 0; - Rcpp::CharacterVector names = fDf.attr("names"); - Bool_t found = false; - while (i < size) { - if (names[i] == fName.Data()) { - found = true; - break; - } - i++; - } - if (found) fDf[fName.Data()] = obj.fDf[obj.fName.Data()]; - else { - Rcpp::List nDf(size + 1); - Rcpp::CharacterVector nnames(size + 1); - for (i = 0; i < size; i++) { - nDf[i] = obj.fDf[i] ; - nnames[i] = names[i]; - } - nDf[size] = obj.fDf[obj.fName.Data()]; - nnames[size] = fName.Data(); - - nDf.attr("class") = obj.fDf.attr("class") ; - nDf.attr("row.names") = obj.fDf.attr("row.names") ; - nDf.attr("names") = nnames ; - fDf = nDf; - } - - 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_t size = fDf.size(), i = 0; - Rcpp::CharacterVector names = fDf.attr("names"); - Bool_t found = false; - while (i < size) { - if (names[i] == fName.Data()) { - found = true; - break; - } - i++; - } - if (found) fDf[fName.Data()] = var; - else { - Rcpp::List nDf(size + 1); - Rcpp::CharacterVector nnames(size + 1); - for (i = 0; i < size; i++) { - nDf[i] = fDf[i] ; - nnames[i] = names[i]; - } - 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 ; - fDf = nDf; - } - return *this; - } - 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; - 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 columns - \return number of cols - */ - Int_t GetNcols() { return df.size(); } - /** - Method to get the number of rows - \return number of rows - */ - Int_t GetNrows() { return df.nrows(); } - /** - Method to get labels of dataframe - \return columns names - */ - TVectorString GetColNames() - { - Rcpp::CharacterVector names = df.attr("names"); - TVectorString rnames(GetNcols()); - for (Int_t i = 0; i < GetNcols(); i++) rnames[i] = names[i]; - 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 number of the column to print - */ - void Print(const Char_t *label = "") - { - TRFunctionImport print("print"); - if (label && !label[0]) { - // label is "" - print(df); - } else { - print(df[label]); - } - } - ClassDefOverride(TRDataFrame, 0) // - }; - } -} - - - -#endif diff --git a/bindings/r/inc/TRDataFrame__ctors.h b/bindings/r/inc/TRDataFrame__ctors.h deleted file mode 100644 index 29f58461fb5bd..0000000000000 --- a/bindings/r/inc/TRDataFrame__ctors.h +++ /dev/null @@ -1,156 +0,0 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- -// -// TRIDataFrame_Impl__ctors.h: based in Rcpp R/C++ interface class library -- generated helper code for TRDataFrame_Impl.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_TRDataFrame_Impl_ctors -#define ROOT_R_TRDataFrame_Impl_ctors - - -template -TRDataFrame(const T1 &t1) -{ - df = Rcpp::DataFrame::create(t1) ; -} - - -template -TRDataFrame(const T1 &t1, const T2 &t2) -{ - df = Rcpp::DataFrame::create(t1, t2) ; -} - - -template -TRDataFrame(const T1 &t1, const T2 &t2, const T3 &t3) -{ - df = Rcpp::DataFrame::create(t1, t2, t3) ; -} - - -template -TRDataFrame(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4) ; -} - - -template -TRDataFrame(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5) ; -} - - -template -TRDataFrame(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6) ; -} - - -template -TRDataFrame(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7) ; -} - - -template -TRDataFrame(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7, const T8 &t8) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19) ; -} - - -template -TRDataFrame(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) -{ - df = Rcpp::DataFrame::create(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/inc/TRFunctionExport.h b/bindings/r/inc/TRFunctionExport.h deleted file mode 100644 index 40252b55fd6f9..0000000000000 --- a/bindings/r/inc/TRFunctionExport.h +++ /dev/null @@ -1,189 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata Omar.Zapata@cern.ch 16/06/2013 - - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#ifndef ROOT_R_TRFunctionExport -#define ROOT_R_TRFunctionExport - -#include - - -namespace ROOT { - namespace R { - - /** - \class TRFunctionExport - - 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
- - https://root.cern/doc/master/NumericalMinimization_8C.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"]< https://oproject.org/pages/ROOT R Users Guide
- - */ - - - class TRInterface; - class TRFunctionExport: public TObject { - friend class TRInterface; - friend SEXP Rcpp::wrap(const TRFunctionExport &f); - protected: - TRInternalFunction *f; //Internar Function to export - public: - /** - Default TRFunctionExport constructor - */ - TRFunctionExport(); - - /** - Default TRFunctionExport destructor - */ - ~TRFunctionExport() - { - if (f) delete f; - } - /** - TRFunctionExport copy constructor - \param fun other TRFunctionExport - */ - TRFunctionExport(const TRFunctionExport &fun); - - /** - TRFunctionExport template constructor that supports a lot of function's prototypes - \param fun supported function to be wrapped by Rcpp - */ - template TRFunctionExport(T fun) - { - f = new TRInternalFunction(fun); - } - - /** - function to assign function to export, - template method that supports a lot of function's prototypes - \param fun supported function to be wrapped by Rcpp - */ - template void SetFunction(T fun) - { - f = new TRInternalFunction(fun); - } - - ClassDefOverride(TRFunctionExport, 0) // - }; - } -} - - - -#endif diff --git a/bindings/r/inc/TRFunctionImport.h b/bindings/r/inc/TRFunctionImport.h deleted file mode 100644 index bc2e75ee0de52..0000000000000 --- a/bindings/r/inc/TRFunctionImport.h +++ /dev/null @@ -1,179 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata Omar.Zapata@cern.ch 28/06/2015 - - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * 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 - - -#include - -#include - -namespace ROOT { - namespace R { - - /** - \class TRFunctionImport - 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

- https://oproject.org/pages/ROOT R Users Guide
- - */ - - class TRInterface; - class TRFunctionImport: public TObject { - friend class TRInterface; - friend SEXP Rcpp::wrap(const TRFunctionImport &f); - friend TRFunctionImport Rcpp::as<>(SEXP); - - protected: - 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 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 constructor - \param obj TRObject object - */ - TRFunctionImport(TRObject &obj); - - ~TRFunctionImport() - { - if (f) delete f; - } - SEXP operator()() - { - return (*f)(); - } -#include - ClassDefOverride(TRFunctionImport, 0) // - }; - - template<> inline TRObject::operator TRFunctionImport() - { - return (SEXP)fObj; - } - } -} - - - -#endif diff --git a/bindings/r/inc/TRFunctionImport__oprtr.h b/bindings/r/inc/TRFunctionImport__oprtr.h deleted file mode 100644 index 66ab755ff313f..0000000000000 --- a/bindings/r/inc/TRFunctionImport__oprtr.h +++ /dev/null @@ -1,133 +0,0 @@ -// -*- 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 -TRObject operator()(const T1 &t1) const -{ - return (*f)(t1) ; -} - -template -TRObject operator()(const T1 &t1, const T2 &t2) const -{ - return (*f)(t1, t2) ; -} - -template -TRObject operator()(const T1 &t1, const T2 &t2, const T3 &t3) const -{ - return (*f)(t1, t2, t3) ; -} - -template -TRObject operator()(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) const -{ - return (*f)(t1, t2, t3, t4) ; -} - -template -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 -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 -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 -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 -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 -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 -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 -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 -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 -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 -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 -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 -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 -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 -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 -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) ; -} - -#endif diff --git a/bindings/r/inc/TRInterface.h b/bindings/r/inc/TRInterface.h deleted file mode 100644 index bff0e946ec08a..0000000000000 --- a/bindings/r/inc/TRInterface.h +++ /dev/null @@ -1,328 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata Omar.Zapata@cern.ch 29/05/2013 - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ - -#ifndef ROOT_R_TRInterface -#define ROOT_R_TRInterface - -#include - -#include - -#include - -#include - -#include - -/** - @namespace ROOT::R - namespace associated R package for ROOT. - */ -namespace ROOT { - namespace R { - /** - \class TRInterface - ROOT R was implemented using the - R Project library and the modules - Rcpp and - RInside -

Users Guide

- https://oproject.org/pages/ROOT R Users Guide
- - */ - - - /** -

TRInterface class

- -

- The TRInterface class lets you process 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 operators [],<< 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 - */ - class TRInterface: public TObject { - protected: - RInside *fR; - TThread *th; - public: - //Proxy class to use operators for assignation Ex: r["name"]=object - class Binding { - public: - Binding(TRInterface *rnt, TString name): fInterface(rnt), fName(name) {} - Binding(const Binding &obj) { - fInterface = obj.fInterface; - fName = obj.fName; - } - Binding &operator=(const Binding &obj) - { - fInterface = obj.fInterface; - fName = obj.fName; - return *this; - } - template Binding &operator=(const T &data) - { - fInterface->Assign(data, fName); - return *this; - } - Binding &operator=(const TRFunctionExport &fun) - { - //The method assign is not a template for a function - fInterface->Assign(fun, fName); - return *this; - } - - Binding &operator<<(const TRFunctionExport &fun) - { - //The method assign is not a template for a function - 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(); - return *this; - } - - template Binding &operator <<(T var) - { - fInterface->Assign(var, fName); - return *this; - } -#include - template operator T() - { - return fInterface->Eval(fName); - } - - private: - TRInterface *fInterface; - TString fName; - }; - private: - /** - The command line arguments are by default 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 argv default null - \param loadRcpp default true - \param verbose default false - \param interactive default true - */ - TRInterface(const Int_t argc = 0, const Char_t *argv[] = NULL, const Bool_t loadRcpp = true, - const Bool_t verbose = false, const Bool_t interactive = true); - - 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 ans reference to TRObject - \return an true or false if the execution was successful 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); - - // "unhide" TObject::Execute methods. - using TObject::Execute; - - /** - 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); - - - /** - Template method to assign C++ variables into R environment - \param var any R wrappable datatype - \param name name of the variable in R's environment - */ - 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 environment. - fR->assign(var, name.Data()); - } - /** - Method to assign TRFunctionExport in R's environment - \param fun TRFunctionExport - \param name name of the variable in R's environment - */ - void Assign(const TRFunctionExport &fun, const TString &name); - /** - Method to assign TRDataFrame in R's environment - \param df TRDataFrame - \param name name of the variable in R's environment - */ - void Assign(const TRDataFrame &df, const TString &name); - - /** - Method to get a R prompt to work interactively with tab completion 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(); - - ClassDefOverride(TRInterface, 0) - }; - } -} - -inline ROOT::R::TRInterface &operator<<(ROOT::R::TRInterface &r, TString code) -{ - r.Execute(code); - return r; -} - -#endif diff --git a/bindings/r/inc/TRInterface_Binding.h b/bindings/r/inc/TRInterface_Binding.h deleted file mode 100644 index d897d0a22b1c2..0000000000000 --- a/bindings/r/inc/TRInterface_Binding.h +++ /dev/null @@ -1,940 +0,0 @@ -// Author: Omar Zapata 2015 - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ - -#ifndef ROOT_R_TRInterface_Binding -#define ROOT_R_TRInterface_Binding - -template -Binding &operator=(OUT(*fun)(void)) -{ - fInterface->Assign(TRFunctionExport(fun), fName); - return *this; -} - -template -Binding &operator=(OUT(*fun)(U0 u0)) -{ - fInterface->Assign(TRFunctionExport(fun), fName); - return *this; -} - -template -Binding &operator=(OUT(*fun)(U0 u0, U1 u1)) -{ - fInterface->Assign(TRFunctionExport(fun), fName); - return *this; -} - -template -Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2)) -{ - fInterface->Assign(TRFunctionExport(fun), fName); - return *this; -} - -template -Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3)) -{ - fInterface->Assign(TRFunctionExport(fun), fName); - return *this; -} - -template -Binding &operator=(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4)) -{ - 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(TRFunctionExport(fun), fName); - return *this; -} -//////////////////////////// -//Overload for Operator < -Binding &operator<<(OUT(*fun)(void)) -{ - fInterface->Assign(TRFunctionExport(fun), fName); - return *this; -} - -template -Binding &operator<<(OUT(*fun)(U0 u0)) -{ - fInterface->Assign(TRFunctionExport(fun), fName); - return *this; -} - -template -Binding &operator<<(OUT(*fun)(U0 u0, U1 u1)) -{ - fInterface->Assign(TRFunctionExport(fun), fName); - return *this; -} - -template -Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2)) -{ - fInterface->Assign(TRFunctionExport(fun), fName); - return *this; -} - -template -Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3)) -{ - fInterface->Assign(TRFunctionExport(fun), fName); - return *this; -} - -template -Binding &operator<<(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4)) -{ - 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(TRFunctionExport(fun), fName); - return *this; -} -#endif diff --git a/bindings/r/inc/TRInternalFunction.h b/bindings/r/inc/TRInternalFunction.h deleted file mode 100644 index 65bc81ebb038e..0000000000000 --- a/bindings/r/inc/TRInternalFunction.h +++ /dev/null @@ -1,64 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata Omar.Zapata@cern.ch 07/06/2014 - - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#ifndef ROOT_R_TRInternalFunction -#define ROOT_R_TRInternalFunction - -#include - -//________________________________________________________________________________________________________ -/** - This is a class to support deprecated method to pass function to R's Environment, - based in Rcpp::InternalFunction - - -*/ - - -namespace Rcpp { - RCPP_API_CLASS(TRInternalFunction_Impl) - { -public: - - RCPP_GENERATE_CTOR_ASSIGN(TRInternalFunction_Impl) - -#if RCPP_VERSION >= Rcpp_Version(1,0,13) - template - TRInternalFunction_Impl(OUT(*fun)(T...)) - { - set(Rcpp::XPtr< Rcpp::CppFunctionN >(new Rcpp::CppFunctionN(fun), false)); - } -#else -#include -#endif - void update(SEXP) {} -private: - - inline void set(SEXP xp) { - Rcpp::Environment RCPP = Rcpp::Environment::Rcpp_namespace() ; - Rcpp::Function intf = RCPP["internal_function"] ; - Storage::set__(intf(xp)) ; - } - - }; - - -} - - -namespace ROOT { - namespace R { - - typedef Rcpp::TRInternalFunction_Impl TRInternalFunction ; - } -} - -#endif diff --git a/bindings/r/inc/TRInternalFunction__ctors.h b/bindings/r/inc/TRInternalFunction__ctors.h deleted file mode 100644 index 20c67f6f5cb8a..0000000000000 --- a/bindings/r/inc/TRInternalFunction__ctors.h +++ /dev/null @@ -1,607 +0,0 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- -// -// TRInternalFunction_Impl__ctors.h: based in Rcpp R/C++ interface class library -- generated helper code for TRInternalFunction_Impl.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_TRInternalFunction_Impl_ctors -#define ROOT_R_TRInternalFunction_Impl_ctors - -template -TRInternalFunction_Impl(OUT(*fun)(void)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction0 >(new Rcpp::CppFunction0(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction1 >(new Rcpp::CppFunction1(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0, U1 u1)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction2 >(new Rcpp::CppFunction2(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0, U1 u1, U2 u2)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction3 >(new Rcpp::CppFunction3(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction4 >(new Rcpp::CppFunction4(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction5 >(new Rcpp::CppFunction5(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction6 >(new Rcpp::CppFunction6(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction7 >(new Rcpp::CppFunction7(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction8 >(new Rcpp::CppFunction8(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction9 >(new Rcpp::CppFunction9(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction10 >(new Rcpp::CppFunction10(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(OUT(*fun)(U0 u0, U1 u1, U2 u2, U3 u3, U4 u4, U5 u5, U6 u6, U7 u7, U8 u8, U9 u9, U10 u10)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction11 >(new Rcpp::CppFunction11(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction12 >(new Rcpp::CppFunction12(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction13 >(new Rcpp::CppFunction13(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction14 >(new Rcpp::CppFunction14(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction15 >(new Rcpp::CppFunction15(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction16 >(new Rcpp::CppFunction16(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction17 >(new Rcpp::CppFunction17(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction18 >(new Rcpp::CppFunction18(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction19 >(new Rcpp::CppFunction19(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction20 >(new Rcpp::CppFunction20(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction21 >(new Rcpp::CppFunction21(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction22 >(new Rcpp::CppFunction22(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction23 >(new Rcpp::CppFunction23(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction24 >(new Rcpp::CppFunction24(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction25 >(new Rcpp::CppFunction25(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction26 >(new Rcpp::CppFunction26(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction27 >(new Rcpp::CppFunction27(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction28 >(new Rcpp::CppFunction28(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction29 >(new Rcpp::CppFunction29(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction30 >(new Rcpp::CppFunction30(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction31 >(new Rcpp::CppFunction31(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction32 >(new Rcpp::CppFunction32(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction33 >(new Rcpp::CppFunction33(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction34 >(new Rcpp::CppFunction34(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction35 >(new Rcpp::CppFunction35(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction36 >(new Rcpp::CppFunction36(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction37 >(new Rcpp::CppFunction37(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction38 >(new Rcpp::CppFunction38(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction39 >(new Rcpp::CppFunction39(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction40 >(new Rcpp::CppFunction40(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction41 >(new Rcpp::CppFunction41(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction42 >(new Rcpp::CppFunction42(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction43 >(new Rcpp::CppFunction43(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction44 >(new Rcpp::CppFunction44(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction45 >(new Rcpp::CppFunction45(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction46 >(new Rcpp::CppFunction46(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction47 >(new Rcpp::CppFunction47(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction48 >(new Rcpp::CppFunction48(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction49 >(new Rcpp::CppFunction49(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction50 >(new Rcpp::CppFunction50(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction51 >(new Rcpp::CppFunction51(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction52 >(new Rcpp::CppFunction52(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction53 >(new Rcpp::CppFunction53(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction54 >(new Rcpp::CppFunction54(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction55 >(new Rcpp::CppFunction55(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction56 >(new Rcpp::CppFunction56(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction57 >(new Rcpp::CppFunction57(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction58 >(new Rcpp::CppFunction58(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction59 >(new Rcpp::CppFunction59(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction60 >(new Rcpp::CppFunction60(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction61 >(new Rcpp::CppFunction61(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction62 >(new Rcpp::CppFunction62(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction63 >(new Rcpp::CppFunction63(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction64 >(new Rcpp::CppFunction64(fun), false)) ; -} - - - - -template -TRInternalFunction_Impl(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)) -{ - set(Rcpp::XPtr< Rcpp::CppFunction65 >(new Rcpp::CppFunction65(fun), false)) ; -} - - - -#endif - diff --git a/bindings/r/inc/TRObject.h b/bindings/r/inc/TRObject.h deleted file mode 100644 index 0f90f7abcf060..0000000000000 --- a/bindings/r/inc/TRObject.h +++ /dev/null @@ -1,200 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata Omar.Zapata@cern.ch 29/05/2013 - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#ifndef ROOT_R_TRObject -#define ROOT_R_TRObject - -#include - - -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 operators 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

- https://oproject.org/pages/ROOT R Users Guide
- - */ - class TRObject: public TObject { - friend SEXP Rcpp::wrap(const TRObject &f); - private: - Rcpp::RObject fObj; //internal Rcpp::RObject - Bool_t fStatus;//status tell if is a valid object - public: - /** - Default constructor - */ - TRObject(): TObject() {}; - /** - 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 - */ - 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()); - } - - 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 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 unknown value"); - return T(); - } - } - - template T operator=(TRObject &obj) - { - return ::Rcpp::as(obj); - } - - operator SEXP() - { - return fObj; - } - - operator SEXP() const - { - 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 unknown value"); - return T(); - } - } - ClassDefOverride(TRObject, 0) // - }; - - } -} - - -#endif diff --git a/bindings/r/src/RExports.cxx b/bindings/r/src/RExports.cxx deleted file mode 100644 index dee4905f3d784..0000000000000 --- a/bindings/r/src/RExports.cxx +++ /dev/null @@ -1,118 +0,0 @@ -// Author: Omar Zapata Omar.Zapata@cern.ch 2014 - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#include -#include -#include -#include - -namespace ROOT { - namespace R { - const Rcpp::internal::NamedPlaceHolder &Label(Rcpp::_); - } -} - -namespace Rcpp { -//TVectorT - template<> SEXP wrap(const TVectorT &v) - { - std::vector vec(v.GetMatrixArray(), v.GetMatrixArray() + v.GetNoElements()); - return wrap(vec); - } - - template<> TVectorT as(SEXP v) - { - std::vector vec =::Rcpp::as >(v); - return TVectorT(vec.size(), vec.data()); - } - - template<> SEXP wrap(const TVectorT &v) - { - std::vector vec(v.GetMatrixArray(), v.GetMatrixArray() + v.GetNoElements()); - return wrap(vec); - } - - template<> TVectorT as(SEXP v) - { - std::vector vec =::Rcpp::as >(v); - return TVectorT(vec.size(), vec.data()); - } - -//TMatrixT - template<> SEXP wrap(const TMatrixT &m) - { - Int_t rows = m.GetNrows(); - Int_t cols = m.GetNcols(); - Double_t *data = new Double_t[rows * cols]; - m.GetMatrix2Array(data, "F"); //ROOT has a bug here(Fixed) - NumericMatrix mat(rows, cols, data); - return wrap(mat); - } - - template<> TMatrixT as(SEXP m) - { - NumericMatrix mat =::Rcpp::as(m); - return TMatrixT(mat.rows(), mat.cols(), mat.begin(), "F"); - } - - template<> SEXP wrap(const TMatrixT &m) - { - Int_t rows = m.GetNrows(); - Int_t cols = m.GetNcols(); - Float_t *data = new Float_t[rows * cols]; - m.GetMatrix2Array(data, "F"); //ROOT has a bug here(Fixed) - NumericMatrix mat(rows, cols, data); - return wrap(mat); - } - - template<> TMatrixT as(SEXP m) - { - NumericMatrix mat =::Rcpp::as(m); - std::vector dat = Rcpp::as>(mat); - return TMatrixT(mat.rows(), mat.cols(), &dat[0], "F"); - } - -//TRObject - template<> SEXP wrap(const ROOT::R::TRObject &obj) - { - return obj.fObj; - } - - template<> ROOT::R::TRObject as(SEXP obj) - { - return ROOT::R::TRObject(obj); - } -//TRDataFrame - template<> SEXP wrap(const ROOT::R::TRDataFrame &obj) - { - return obj.df; - } - - template<> ROOT::R::TRDataFrame as(SEXP obj) - { - 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 { - namespace R { - VARIABLE_IS_NOT_USED SEXP ModuleSymRef = NULL; - } -} diff --git a/bindings/r/src/TRCompletion.cxx b/bindings/r/src/TRCompletion.cxx deleted file mode 100644 index 1cd2080f2b107..0000000000000 --- a/bindings/r/src/TRCompletion.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// Author: Omar Zapata Omar.Zapata@cern.ch 2014 - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#include"TRCompletion.h" -namespace ROOT { - namespace R { - - SEXP RComp_assignBufferSym, - RComp_assignStartSym, - RComp_assignEndSym, - RComp_assignTokenSym, - RComp_completeTokenSym, - RComp_getFileCompSym, - RComp_retrieveCompsSym; - - SEXP rcompgen_rho; - } -} - -char *ROOT::R::R_completion_generator(const char *text, int state) -{ - // If this is a new word to complete, initialize now. This - // involves saving 'text' to somewhere R can get it, calling - // completeToken(), and retrieving the completions. - //NOTE: R based code and ajusted to Rcpp - static int list_index, ncomp; - static char **compstrings; - - - if (!state) { - int i; - SEXP completions, - assignCall = PROTECT(Rf_lang2(ROOT::R::RComp_assignTokenSym, Rf_mkString(text))), - completionCall = PROTECT(Rf_lang1(ROOT::R::RComp_completeTokenSym)), - retrieveCall = PROTECT(Rf_lang1(ROOT::R::RComp_retrieveCompsSym)); - const void *vmax = vmaxget(); - - Rf_eval(assignCall, ROOT::R::rcompgen_rho); - Rf_eval(completionCall, ROOT::R::rcompgen_rho); - PROTECT(completions = Rf_eval(retrieveCall, ROOT::R::rcompgen_rho)); - list_index = 0; - ncomp = Rf_length(completions); - if (ncomp > 0) { - compstrings = (char **) malloc(ncomp * sizeof(char *)); - if (!compstrings) return (char *)NULL; - for (i = 0; i < ncomp; i++) - compstrings[i] = strdup(Rf_translateChar(STRING_ELT(completions, i))); - } - UNPROTECT(4); - vmaxset(vmax); - } - - if (list_index < ncomp) - return compstrings[list_index++]; - else { - /* nothing matched or remaining, returns NULL. */ - if (ncomp > 0) free(compstrings); - } - return (char *)NULL; -} - - -char **ROOT::R::R_custom_completion(const char *text, int start, int end) -{ - //NOTE: R based code and ajusted to Rcpp - char **matches = (char **)NULL; - SEXP infile, - linebufferCall = PROTECT(Rf_lang2(ROOT::R::RComp_assignBufferSym, - Rf_mkString(rl_line_buffer))), - startCall = PROTECT(Rf_lang2(ROOT::R::RComp_assignStartSym, Rf_ScalarInteger(start))), - endCall = PROTECT(Rf_lang2(ROOT::R::RComp_assignEndSym, Rf_ScalarInteger(end))); - SEXP filecompCall; - - // We don't want spaces appended at the end. It's nedded everytime - // since readline>=6 resets it to ' ' - rl_completion_append_character = '\0'; - - Rf_eval(linebufferCall, ROOT::R::rcompgen_rho); - Rf_eval(startCall, ROOT::R::rcompgen_rho); - Rf_eval(endCall, ROOT::R::rcompgen_rho); - UNPROTECT(3); - matches = rl_completion_matches(text, ROOT::R::R_completion_generator); - filecompCall = PROTECT(Rf_lang1(ROOT::R::RComp_getFileCompSym)); - infile = PROTECT(Rf_eval(filecompCall, ROOT::R::rcompgen_rho)); - if (!Rf_asLogical(infile)) rl_attempted_completion_over = 1; - UNPROTECT(2); - return matches; -} diff --git a/bindings/r/src/TRCompletion.h b/bindings/r/src/TRCompletion.h deleted file mode 100644 index fc9e1bd5069f0..0000000000000 --- a/bindings/r/src/TRCompletion.h +++ /dev/null @@ -1,49 +0,0 @@ -// @(#)root/r:$Id$ -// Author: Omar Zapata 29/08/2013 -// The tab-completion interface was based in R's readline code. -#ifndef ROOT_R_TRCompletion -#define ROOT_R_TRCompletion - -#include - -#if !defined(_READLINE_H_) - -#if !defined (PARAMS) -# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) -# define PARAMS(protos) protos -# else -# define PARAMS(protos) () -# endif -#endif -extern "C" -{ - typedef char **rl_completion_func_t PARAMS((const char *, int, int)); - typedef char *rl_compentry_func_t PARAMS((const char *, int)); - extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *)); - extern char *readline PARAMS((const char *)); - extern void add_history PARAMS((const char *)); - extern rl_completion_func_t *rl_attempted_completion_function; - extern char *rl_line_buffer; - extern int rl_completion_append_character; - extern int rl_attempted_completion_over; -} -#endif //_READLINE_H_ - -namespace ROOT { - namespace R { - char *R_completion_generator(const char *text, int state); - char **R_custom_completion(const char *text, int start, int end); - //Readline variables. - extern SEXP - RComp_assignBufferSym, - RComp_assignStartSym, - RComp_assignEndSym, - RComp_assignTokenSym, - RComp_completeTokenSym, - RComp_getFileCompSym, - RComp_retrieveCompsSym; - extern SEXP rcompgen_rho; - } -} - -#endif diff --git a/bindings/r/src/TRDataFrame.cxx b/bindings/r/src/TRDataFrame.cxx deleted file mode 100644 index 0e1608b91d6e6..0000000000000 --- a/bindings/r/src/TRDataFrame.cxx +++ /dev/null @@ -1,31 +0,0 @@ -// Author: Omar Zapata Omar.Zapata@cern.ch 2015 - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#include - - -using namespace ROOT::R; - -//______________________________________________________________________________ -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 deleted file mode 100644 index 792556e8ae1fc..0000000000000 --- a/bindings/r/src/TRFunctionExport.cxx +++ /dev/null @@ -1,26 +0,0 @@ -// Author: Omar Zapata Omar.Zapata@cern.ch 2015 - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#include - -using namespace ROOT::R; - - -//______________________________________________________________________________ -TRFunctionExport::TRFunctionExport(): TObject() -{ - f = NULL; -} - -//______________________________________________________________________________ -TRFunctionExport::TRFunctionExport(const TRFunctionExport &fun): TObject(fun) -{ - f = fun.f; -} - diff --git a/bindings/r/src/TRFunctionImport.cxx b/bindings/r/src/TRFunctionImport.cxx deleted file mode 100644 index 7004a8332adbb..0000000000000 --- a/bindings/r/src/TRFunctionImport.cxx +++ /dev/null @@ -1,51 +0,0 @@ -// Author: Omar Zapata Omar.Zapata@cern.ch 2015 - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#include -#include - -//______________________________________________________________________________ -/* Begin_Html -End_Html -*/ - - -using namespace ROOT::R; - - - -//______________________________________________________________________________ -TRFunctionImport::TRFunctionImport(const TRFunctionImport &fun): TObject(fun) -{ - f = fun.f; -} - -//______________________________________________________________________________ -TRFunctionImport::TRFunctionImport(const TString &name) -{ - f = new Rcpp::Function(name.Data()); -} - -//______________________________________________________________________________ -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) -{ - f = new Rcpp::Function(obj); -} diff --git a/bindings/r/src/TRInterface.cxx b/bindings/r/src/TRInterface.cxx deleted file mode 100644 index f391c9bf1c8a0..0000000000000 --- a/bindings/r/src/TRInterface.cxx +++ /dev/null @@ -1,300 +0,0 @@ -// Author: Omar Zapata Omar.Zapata@cern.ch 2014 - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#include -#include"TRCompletion.h" -#include - -extern "C" -{ -#include -#include -} -#include -#include - -#if defined(HAS_X11) -#include -#include "TROOT.h" -#include "TEnv.h" -#endif -using namespace ROOT::R; - -static ROOT::R::TRInterface *gR = nullptr; -static Bool_t statusEventLoop; - -TRInterface::TRInterface(const Int_t argc, const Char_t *argv[], const Bool_t loadRcpp, const Bool_t verbose, - const Bool_t interactive) - : TObject() -{ - if (RInside::instancePtr()) throw std::runtime_error("Can only have one TRInterface instance"); - fR = new RInside(argc, argv, loadRcpp, verbose, interactive); - - //Installing the readline callbacks for completion in the - //method Interactive - rcompgen_rho = R_FindNamespace(Rf_mkString("utils")); - RComp_assignBufferSym = Rf_install(".assignLinebuffer"); - RComp_assignStartSym = Rf_install(".assignStart"); - RComp_assignEndSym = Rf_install(".assignEnd"); - RComp_assignTokenSym = Rf_install(".assignToken"); - RComp_completeTokenSym = Rf_install(".completeToken"); - RComp_getFileCompSym = Rf_install(".getFileComp"); - 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 defined(HAS_X11) - if (!gROOT->IsBatch()) { - if (gEnv->GetValue("X11.XInitThread", 1)) { - // Must be very first call before any X11 call !! - if (!XInitThreads()) - Warning("OpenDisplay", "system has no X11 thread support"); - } - } -#endif - if (osname == "Linux") { - Execute("options(device='x11')"); - } else { - Execute("options(device='quartz')"); - } - -} - -TRInterface::~TRInterface() -{ - statusEventLoop = kFALSE; - if (th) delete th; - if (fR) delete fR; - if (gR == this) gR = nullptr; -} - -//______________________________________________________________________________ -Int_t TRInterface::Eval(const TString &code, TRObject &ans) -{ - SEXP fans; - - Int_t rc = kFALSE; - try { - rc = fR->parseEval(code.Data(), fans); - } catch (Rcpp::exception &__ex__) { - Error("Eval", "%s", __ex__.what()); - forward_exception_to_r(__ex__) ; - } catch (...) { - Error("Eval", "Can execute the requested code: %s", code.Data()); - } - ans = fans; - ans.SetStatus((rc == 0) ? kTRUE : kFALSE); - return rc; -} - -//______________________________________________________________________________ -void TRInterface::Execute(const TString &code) -{ - try { - - fR->parseEvalQ(code.Data()); - } catch (Rcpp::exception &__ex__) { - Error("Execute", "%s", __ex__.what()); - forward_exception_to_r(__ex__) ; - } catch (...) { - Error("Execute", "Can execute the requested code: %s", code.Data()); - } -} - -//______________________________________________________________________________ -TRObject TRInterface::Eval(const TString &code) -{ -// Execute R code. -//The RObject result of execution is returned in TRObject - - SEXP ans; - - int rc = kFALSE; - try { - rc = fR->parseEval(code.Data(), ans); - } catch (Rcpp::exception &__ex__) { - Error("Eval", "%s", __ex__.what()); - forward_exception_to_r(__ex__) ; - } catch (...) { - Error("Eval", "Can execute the requested code: %s", code.Data()); - } - - return TRObject(ans, (rc == 0) ? kTRUE : kFALSE); -} - - -void TRInterface::SetVerbose(Bool_t status) -{ - //verbose mode shows you all the procedures in stdout/stderr - //very important to debug and to see the results. - fR->setVerbose(status); -} - -//______________________________________________________________________________ -TRInterface::Binding TRInterface::operator[](const TString &name) -{ - return Binding(this, name); -} - -//______________________________________________________________________________ -void TRInterface::Assign(const TRFunctionExport &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() -{ - while (kTRUE) { - Char_t *line = readline("[r]:"); - if (!line) continue; - if (std::string(line) == ".q") break; - Execute(line); - if (*line) add_history(line); - free(line); - } -} - - -//______________________________________________________________________________ -TRInterface *TRInterface::InstancePtr() -{ - if (!gR) { - const Char_t *R_argv[] = {"rootr", "--gui=none", "--no-save", "--no-readline", - "--silent", "--vanilla", "--slave"}; - gR = new TRInterface(7, R_argv, true, false, false); - } - gR->ProcessEventsLoop(); - return gR; -} - -//______________________________________________________________________________ -TRInterface &TRInterface::Instance() -{ - return *TRInterface::InstancePtr(); -} - -namespace { - -// Per CRAN policy, an R package name starts with a letter, contains only ASCII -// letters, digits, and dots, and does not end with a dot. Restricting to this -// set is a helpful validation step for the user and prevents R-source -// injection via the string concatenation done in IsInstalled / Require / -// Install below. -bool IsValidRPackageName(const TString &pkg) -{ - const Ssiz_t n = pkg.Length(); - if (n == 0) - return false; - const char first = pkg[0]; - if (!((first >= 'A' && first <= 'Z') || (first >= 'a' && first <= 'z'))) - return false; - for (Ssiz_t i = 1; i < n; ++i) { - const char c = pkg[i]; - const Bool_t ok = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.'; - if (!ok) - return false; - } - return pkg[n - 1] != '.'; -} - -// Allow only an http(s)/ftp/file URL with no characters that could break -// out of the R single-quoted literal in Install(). -bool IsValidRReposUrl(const TString &repos) -{ - const Ssiz_t n = repos.Length(); - if (n == 0) - return false; - const char *prefixes[] = {"http://", "https://", "ftp://", "file://"}; - Bool_t prefixOk = false; - for (const char *s : prefixes) { - if (repos.BeginsWith(s)) { - prefixOk = true; - break; - } - } - if (!prefixOk) - return false; - for (Ssiz_t i = 0; i < n; ++i) { - const char c = repos[i]; - if (c == '\'' || c == '\\' || c == '`' || c == ';' || c == '\n' || c == '\r') - return false; - } - return true; -} - -} // namespace - -//______________________________________________________________________________ -Bool_t TRInterface::IsInstalled(TString pkg) -{ - if (!IsValidRPackageName(pkg)) { - Error("IsInstalled", "Invalid R package name: %s", pkg.Data()); - return kFALSE; - } - TString cmd = "is.element('" + pkg + "', installed.packages()[,1])"; - return this->Eval(cmd).As(); -} - -//______________________________________________________________________________ -Bool_t TRInterface::Require(TString pkg) -{ - if (!IsValidRPackageName(pkg)) { - Error("Require", "Invalid R package name: %s", pkg.Data()); - return kFALSE; - } - TString cmd = "require('" + pkg + "',quiet=TRUE)"; - return this->Eval(cmd).As(); -} - -//______________________________________________________________________________ -Bool_t TRInterface::Install(TString pkg, TString repos) -{ - if (!IsValidRPackageName(pkg)) { - Error("Install", "Invalid R package name: %s", pkg.Data()); - return kFALSE; - } - if (!IsValidRReposUrl(repos)) { - Error("Install", "Invalid R repository URL: %s", repos.Data()); - return kFALSE; - } - TString cmd = "install.packages('" + pkg + "',repos='" + repos + "',dependencies=TRUE)"; - this->Eval(cmd); - return IsInstalled(pkg); -} - - -#undef _POSIX_C_SOURCE -#include - -//______________________________________________________________________________ -void TRInterface::ProcessEventsLoop() -{ - if (!statusEventLoop) { - th = new TThread([](void */*args */) { - while (statusEventLoop) { - fd_set *fd; - Int_t usec = 10000; - fd = R_checkActivity(usec, 0); - R_runHandlers(R_InputHandlers, fd); - if (gSystem) gSystem->Sleep(100); - } - }); - statusEventLoop = kTRUE; - th->Run(); - } -} diff --git a/bindings/r/src/TRObject.cxx b/bindings/r/src/TRObject.cxx deleted file mode 100644 index 7af239d8907a9..0000000000000 --- a/bindings/r/src/TRObject.cxx +++ /dev/null @@ -1,27 +0,0 @@ -// Author: Omar Zapata Omar.Zapata@cern.ch 2014 - -/************************************************************************* - * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * - * All rights reserved. * - * * - * For the licensing terms see $ROOTSYS/LICENSE. * - * For the list of contributors see $ROOTSYS/README/CREDITS. * - *************************************************************************/ -#include -#include - -using namespace ROOT::R; - -//______________________________________________________________________________ -TRObject::TRObject(SEXP robj): TObject(), fObj(robj), fStatus(kTRUE) { } - - -//______________________________________________________________________________ -void TRObject::operator=(SEXP robj) -{ - fStatus = kTRUE; - fObj = robj; -} - -//______________________________________________________________________________ -TRObject::TRObject(SEXP robj, Bool_t status): fObj(robj), fStatus(status) {} diff --git a/bindings/r/tests/Binding.C b/bindings/r/tests/Binding.C deleted file mode 100644 index 0f0bb773081cb..0000000000000 --- a/bindings/r/tests/Binding.C +++ /dev/null @@ -1,149 +0,0 @@ -// Author: Omar Zapata -#include -#include -#include - -Double_t Function(Double_t x) -{ - return x/(x-1); -} - -Double_t Fun(Double_t x) -{ - return x/(x-1); -} -//overloaded function to test the operator << -Int_t Fun(Int_t x) -{ - return x-1; -} - -void Binding(){ -//creating variables -TVectorD v(3); -std::vector sv(3); -std::array a{ {1,2,3} }; -TString str("ROOTR"); -TMatrixD m(2,2); -Int_t i=9; -Double_t d=2.013; -Float_t f=0.013; - -//assinging values -v[0]=0.01; -v[1]=1.01; -v[2]=2.01; - -sv[0]=0.101; -sv[1]=0.202; -sv[2]=0.303; - -m[0][0]=0.01; -m[0][1]=1.01; -m[1][0]=2.01; -m[1][1]=3.01; - -ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); -// r.SetVerbose(kTRUE); - -//testing operators binding -r["a"]<<1; -r["v"]<>x; -std::cout<>mat; - -r["m"]<>aa; -r["v"]>>v; -r["sv"]>>sv; -r["m"]>>m; -r["b"]>>b; -r["i"]>>i; -r["d"]>>d; -r["f"]>>f; -r["array"]>>a; -r["s"]>>str2; - -mat.Print(); -std::cout<<" array={"< -#include -#include - -class TRF1 { -private: - TF1 *f; -public: - TRF1(std::string name,std::string formula){f=new TF1(name.c_str(),formula.c_str());} - double Eval(double x) { - return f->Eval(x); - } - void Draw(){ - f->Draw(); - } -}; - - -ROOTR_MODULE(rootr) { - ROOT::R::class_( "TRF1" ) - .constructor() - .method( "Eval", &TRF1::Eval ) - .method( "Draw", &TRF1::Draw ) - ; -} - - -void Class() -{ - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - r["rootr"]< -#include -#include -#include - -using namespace ROOT::R; - -void DataFrame() { -//creating variables - TVectorD v(3); - std::vector sv(3); -//std::array a{ {1,2,3} }; - -//assinging values - v[0]=1; - v[1]=2; - v[2]=3; - - sv[0]=0.101; - sv[1]=0.202; - sv[2]=0.303; - - - TRInterface &r=TRInterface::Instance(); -// r.SetVerbose(kTRUE); - std::list names; - names.push_back("v1"); - names.push_back("v2"); - names.push_back("v3"); - - TRDataFrame df(Label["var1"]=v,Label["var2"]=sv,Label["var3"]=sv,Label["strings"]=names); - TRDataFrame df2; - - - r["df"]<>sv; - - r["v"]<>df2; - r["v2"]<> is not supported between Bindings(FIXED NOW)) - df2["v6"]>>df2["v1"]; - - //basic methods - std::cout<<"------------------------------------\n"; - std::cout<<"nrows = "<>df["var1"]; - r["v5"]<>dfm; - dfm.Print(); - - dfm.Print("v1"); - - TMatrixT m=dfm.AsMatrix(); - m.Print(); - - //Error Handling -/* std::cout<<"------------------------------------\n"; - try{ - r["qwe"]< - -using namespace Rcpp ; - -class Foo{ - public: - enum Bla{ FOO, BAR } ; - - Foo( double x_, double y_) : x(x_), y(y_){} - - Foo* clone(){ - return new Foo( x, y) ; - } - - double x, y ; - - void bla(const Foo& other){ - Rprintf( "efez\n" ) ; - } - -} ; - -Foo make_foo(){ return Foo(3, 4) ; } - -RCPP_EXPOSED_CLASS(Foo) - -RCPP_MODULE(Mod){ - - class_("Foo" ) - .constructor() - .method( "clone", &Foo::clone ) - - .field( "x", &Foo::x ) - .field( "y", &Foo::y ) - - .method( "bla", &Foo::bla ) - ; - Rcpp::function( "make_foo", &make_foo ) ; - -} - -void ExpClass() -{ - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - r["Mod"]< -#include - -std::string hello( std::string who, std::string msg){ - std::string result( "hello " ) ; - result += who ; - result += msg; - return result ; -} - -ROOTR_MODULE(rootr){ - ROOT::R::function( "hello", &hello ); -} - -void FunModule() -{ - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - r.SetVerbose(kFALSE); - r["rootr"]< -#include -double funv(TVectorD v) -{ - return v[0] * v[1]; -} - -void funm(TMatrixD m) -{ - m.Print(); -} - -void funs(TString s) -{ - std::cout << "hello " << s.Data() << std::endl; -} - -//this prototype dont work because argument should be -//an object to pass an array. -Double_t fun3(Double_t *x, Double_t *par) -{ - return x[0] * par[0]; -} - -Double_t fun4(Double_t x) -{ - return x * 3;; -} - - -void Functions(TString type = "Import") -{ - 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["funm"] << ROOT::R::TRFunctionExport(funm); - r << "cat(funm(matrix(c(1,2,3,4),2,2)))"; - - r["funs"] << ROOT::R::TRFunctionExport(funs); - - r << "cat(funs('ROOTR'))"; - - r["DiLog"] << ROOT::R::TRFunctionExport(TMath::DiLog); - r << "print(DiLog(2))"; - - r << "x <- seq(0,10,0.01)"; - r << "y <- NULL "; - r << "for(i in seq(along=x)) { \ - y <- c(y,DiLog(i)) \ - }"; - - ROOT::R::TRFunctionExport f4; - f4.SetFunction(fun4); - r["fun4"] << f4; - r << "print(fun4(1))"; - } else { - std::cout << "-----------------------" << std::endl; - std::cout << "Testing FunctionImport " << std::endl; - std::cout << "-----------------------" << std::endl; - ROOT::R::TRFunctionImport print("print"); - print("Hola"); - - ROOT::R::TRFunctionImport c("c"); - ROOT::R::TRFunctionImport require("require"); - ROOT::R::TRFunctionImport plot("plot"); - ROOT::R::TRFunctionImport devoff("dev.off"); -// - ROOT::R::TRFunctionImport sin("sin"); -// ROOT::R::TRFunctionImport options("options"); - 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"); - - - 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; - TVectorF v2=c(11,22,33,44); - print(v); - print(v2); - ROOT::R::TRDataFrame obj=read("training.csv"); - -// ROOT::R::TRDataFrame df(obj.As()); - print(head(Rcpp::wrap(obj))); - print(head(obj)); - 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); - -// require("C50"); - } -} diff --git a/bindings/r/tests/Functor.C b/bindings/r/tests/Functor.C deleted file mode 100644 index f0bb2d9769649..0000000000000 --- a/bindings/r/tests/Functor.C +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -typedef Double_t (*Function)(Double_t); - -class MyFunctor{ -public: - MyFunctor(){ - f=TMath::BesselY1;//here is the function that I want. - } - Double_t doEval(Double_t x) { - return f(x); - } -private: - Function f; -}; - -ROOTR_MODULE(MyFunctorModule) { - ROOT::R::class_( "MyFunctor" ) - .constructor() - .method( "doEval", &MyFunctor::doEval ) -// .method( "otherMethod", &MyFunctor::otherMethod )//you can added more methods adding .method(name,pointer) - ; -} - -void Functor() -{ - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - r["MyFunctorModule"]< -#include -//script to test RExport a TRobjectProxy -void Proxy() -{ - ROOT::R::TRInterface *gR=ROOT::R::TRInterface::InstancePtr(); - gR->SetVerbose(kTRUE); - ////////////////////////// - //Getting values from R // - ////////////////////////// - std::cout << "======Getting values from R ======\n"; - TString s = gR->ParseEval("'ROOTR'"); - - TVectorD v = gR->ParseEval("c(1,2,3,4)"); - std::vector sv=gR->ParseEval("c(1.01,2,3,4)"); - TMatrixD m = gR->ParseEval("matrix(c(1,2,3,4),2,2)"); - - std::cout<<"-----------------------------------"<ParseEval("1.1"); - Float_t f = gR->ParseEval("0.1"); - Int_t i = gR->ParseEval("1"); - - std::cout << d << " " << f << " " << i << std::endl; - - //////////////////////// - //Passing values to R // - ///////////////////////// - - std::cout << "======Passing values to R ======\n"; - gR->Assign(s, "s"); - gR->Parse("print(s)"); - std::cout<<"-----------------------------------"<Parse("print(v)"); - std::cout<<"-----------------------------------"<Assign(sv, "sv"); - gR->Parse("print(sv)"); - std::cout<<"-----------------------------------"<Assign(m, "m"); - gR->Parse("print(m)"); - std::cout<<"-----------------------------------"<Assign(d, "d"); - gR->Parse("print(d)"); - std::cout<<"-----------------------------------"<Assign(f, "f"); - gR->Parse("print(f)"); - std::cout<<"-----------------------------------"<Assign(i, "i"); - gR->Parse("print(i)"); - -} diff --git a/bindings/r/tests/ROOTR.C b/bindings/r/tests/ROOTR.C deleted file mode 100644 index 50b5c6a1cce34..0000000000000 --- a/bindings/r/tests/ROOTR.C +++ /dev/null @@ -1,38 +0,0 @@ -//script to test Modules -#include - -Double_t myFunc(Double_t x) -{ - return cos(x); -} - -void ROOTR() -{ - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - r.SetVerbose(kFALSE); - r.LoadModule("Gpad"); - r.LoadModule("Hist"); - r.LoadModule("Rint"); - - r<<"x<-seq(0,2*pi,by=.1)"; - r<<"c1<-new(TCanvas,'c1','dlnorm')"; - r<<"u <-new(TGraph,length(x),x,dlnorm(x))" ;//TGraph(int,double*,double*) - r<<"u$Draw()"; - - r<<"c2<-new(TCanvas,'c2','DiLog from TMath')"; - r<<"o<- new(TF1,'dilog','TMath::DiLog(x)',0,2*pi)"; - r<<"o$Draw()"; -// - r<<"c3<-new(TCanvas,'c3','Custom')"; - r<<"i <- new(TF1,'f2','[0]*myFunc([1]*x)',0,2*pi)"; - r<<"i$SetRange(0,2*pi)"; - r<<"i$SetParameter(0,4)"; - r<<"i$SetParameter(1,pi/2)"; - r<<"print(i$Eval(0))"; - r<<"print(i$Eval(c(0,pi)))"; - r<<"i$Draw('')"; - -// r<<"gApp<-new(TRint,'ROOTR')"; -// r<<"gApp$ProcessLine('cout<<\"Calling cout from TRint\"<')#loading MathMore to use Special Functions in TRF1 (required for airy) - -c1 <- TCanvas('c1') -dilog <- TF1('dilog','TMath::DiLog(x)') -dilog$Draw() - -c2 <- TCanvas('c2') -lgamma <- TF1('lgamma','ROOT::Math::lgamma(x)') -lgamma$Draw() -# c3 <- TRCanvas('c2') -# airy <- TRF1('lgamma','ROOT::Math::airy_Ai(x)') -# airy$Draw() \ No newline at end of file diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake index 59f0fded3cd5c..0966ae13c3353 100644 --- a/cmake/modules/RootBuildOptions.cmake +++ b/cmake/modules/RootBuildOptions.cmake @@ -148,7 +148,6 @@ ROOT_BUILD_OPTION(opengl ON "Enable support for OpenGL (requires libGL and libGL ROOT_BUILD_OPTION(pyroot ON "Enable support for automatic Python bindings (PyROOT)") ROOT_BUILD_OPTION(pythia8 OFF "Enable support for Pythia 8.x [GPL]") ROOT_BUILD_OPTION(qt6web OFF "Enable support for Qt6 web-based display (requires Qt6::WebEngineCore and Qt6::WebEngineWidgets)") -ROOT_BUILD_OPTION(r OFF "Enable support for R bindings (requires R, Rcpp, and RInside)") ROOT_BUILD_OPTION(roofit ON "Build the advanced fitting package RooFit, and RooStats for statistical tests. If xml is available, also build HistFactory.") ROOT_BUILD_OPTION(roofit_multiprocess OFF "Build RooFit::MultiProcess and multi-process RooFit::TestStatistics classes (requires ZeroMQ >= 4.3.5 built with -DENABLE_DRAFTS and cppzmq).") ROOT_BUILD_OPTION(root7 ON "Build ROOT 7 experimental components of ROOT") @@ -168,7 +167,6 @@ ROOT_BUILD_OPTION(tmva-cpu ON "Build TMVA with CPU support for deep learning (re ROOT_BUILD_OPTION(tmva-cudnn ON "Enable support for cuDNN (default when CUDA is enabled)") ROOT_BUILD_OPTION(tmva-gpu OFF "Build TMVA with GPU support for deep learning (requires CUDA)") ROOT_BUILD_OPTION(tmva-pymva OFF "Enable usage of Python ML libraries in TMVA (requires NumPy, works only with TensorFlow<=2.15)") -ROOT_BUILD_OPTION(tmva-rmva OFF "Enable support for R in TMVA") ROOT_BUILD_OPTION(tmva-sofie OFF "Build TMVA with support for sofie - fast inference code generation (requires protobuf 3)") ROOT_BUILD_OPTION(tpython ON "Build the TPython class that allows you to run Python code from C++") ROOT_BUILD_OPTION(unfold OFF "Enable the unfold package [GPL]") @@ -233,7 +231,6 @@ if(all) set(tmva_defvalue ON) set(tmva-cpu_defvalue ON) set(tmva-pymva_defvalue ON) - set(tmva-rmva_defvalue ON) set(unuran_defvalue ON) set(vdt_defvalue ON) set(vecgeom_defvalue ON) @@ -370,7 +367,8 @@ foreach(opt afdsmgrd afs alien bonjour builtin_afterimage builtin_davix castor c geocad gfal glite globus gsl_shared hdfs html ios jemalloc krb5 ldap memstat minuit2 monalisa oracle proof pyroot-python2 pyroot_legacy pythia6 pythia6_nolink python qt qtgsi qt5web rfio ruby sapdb srp table - tcmalloc vmc xproofd mysql odbc pgsql builtin_cppzmq builtin_zeromq) + tcmalloc vmc xproofd mysql odbc pgsql builtin_cppzmq builtin_zeromq + r tmva-rmva) if(${opt}) message(FATAL_ERROR ">>> '${opt}' is no longer part of ROOT ${ROOT_VERSION} build options.") endif() diff --git a/cmake/modules/RootConfiguration.cmake b/cmake/modules/RootConfiguration.cmake index f2d480428fcc2..9ac64638e1e74 100644 --- a/cmake/modules/RootConfiguration.cmake +++ b/cmake/modules/RootConfiguration.cmake @@ -454,11 +454,6 @@ if (tmva-pymva) else() set(haspymva undef) endif() -if (tmva-rmva) - set(hasrmva define) -else() - set(hasrmva undef) -endif() if (uring) set(hasuring define) else() diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index 8ad1f41b5fff9..f24b718109710 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -752,22 +752,6 @@ elseif(builtin_ftgl) message(SEND_ERROR "FTGL features enabled with \"builtin_ftgl=ON\" require \"opengl=ON\"") endif() -#---Check for R/Rcpp/RInside-------------------------------------------------------------------- -#added search of R packages here to remove multiples searches -if(r) - message(STATUS "Looking for R") - find_package(R COMPONENTS Rcpp RInside) - if(NOT R_FOUND) - if(fail-on-missing) - message(SEND_ERROR "R installation not found and is required ('r' option enabled)") - else() - message(STATUS "R installation not found. Set variable R_DIR to point to your R installation") - message(STATUS "For the time being switching OFF 'r' option") - set(r OFF CACHE BOOL "Disabled because R not found (${r_description})" FORCE) - endif() - endif() -endif() - #---Check for Davix library----------------------------------------------------------- foreach(suffix FOUND INCLUDE_DIR INCLUDE_DIRS LIBRARY LIBRARIES) @@ -1179,18 +1163,10 @@ if(tmva) set(tmva-pymva OFF CACHE BOOL "Disabled because Numpy or Python development package were not found (${tmva-pymva_description})" FORCE) endif() endif() - if (R_FOUND) - #Rmva is enable when r is found and tmva is on - set(tmva-rmva ON) - endif() - if(tmva-rmva AND NOT R_FOUND) - set(tmva-rmva OFF CACHE BOOL "Disabled because R was not found (${tmva-rmva_description})" FORCE) - endif() else() set(tmva-gpu OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-gpu_description})" FORCE) - set(tmva-cudnn OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-rmva_description})" FORCE) + set(tmva-cudnn OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-cudnn_description})" FORCE) set(tmva-pymva OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-pymva_description})" FORCE) - set(tmva-rmva OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-rmva_description})" FORCE) endif(tmva) #---Check for PyROOT--------------------------------------------------------------------- diff --git a/cmake/unix/makepchinput.py b/cmake/unix/makepchinput.py index ce04c0c7b014b..186825fa39e9d 100755 --- a/cmake/unix/makepchinput.py +++ b/cmake/unix/makepchinput.py @@ -251,11 +251,10 @@ def isDirForPCH(dirName, legacyPyROOT): "math/fumili", "math/mlp", "math/quadp", - "math/rtools", "math/splot", "math/unuran", "math/vdt", - "tmva/rmva"] + ] accepted = isAnyPatternInString(PCHPatternsWhitelist,dirName) and \ not isAnyPatternInString(PCHPatternsBlacklist,dirName) diff --git a/config/RConfigure.in b/config/RConfigure.in index 7046c2e10c2e9..2b2370256b4ed 100644 --- a/config/RConfigure.in +++ b/config/RConfigure.in @@ -60,7 +60,6 @@ #@hastmvagpu@ R__HAS_TMVAGPU /**/ #@hastmvacudnn@ R__HAS_CUDNN /**/ #@haspymva@ R__HAS_PYMVA /**/ -#@hasrmva@ R__HAS_RMVA /**/ #@hasuring@ R__HAS_URING /**/ diff --git a/math/CMakeLists.txt b/math/CMakeLists.txt index fddecb1db1a1e..48be60bc84218 100644 --- a/math/CMakeLists.txt +++ b/math/CMakeLists.txt @@ -33,8 +33,4 @@ if(fftw3) add_subdirectory(fftw) endif() -if(r) - add_subdirectory(rtools) -endif() - add_subdirectory(vecops) diff --git a/math/rtools/CMakeLists.txt b/math/rtools/CMakeLists.txt deleted file mode 100644 index 8b484fe54ce17..0000000000000 --- a/math/rtools/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. -# All rights reserved. -# -# For the licensing terms see $ROOTSYS/LICENSE. -# For the list of contributors see $ROOTSYS/README/CREDITS. - -############################################################################ -# CMakeLists.txt file for building ROOT math/rtools package -# @author Pere Mato, CERN -############################################################################ - -ROOT_STANDARD_LIBRARY_PACKAGE(Rtools - HEADERS - Math/RMinimizer.h - SOURCES - src/RMinimizer.cxx - DEPENDENCIES - Core - MathCore - RInterface - NO_CXXMODULE -) - -target_include_directories(Rtools PRIVATE ${R_INCLUDE_DIRS}) - -file(COPY "${CMAKE_SOURCE_DIR}/etc/plugins/ROOT@@Math@@Minimizer/P090_RMinimizer.C" - DESTINATION "${CMAKE_BINARY_DIR}/etc/plugins/ROOT@@Math@@Minimizer/") diff --git a/math/rtools/inc/LinkDef.h b/math/rtools/inc/LinkDef.h deleted file mode 100644 index b2cd34c60ed1d..0000000000000 --- a/math/rtools/inc/LinkDef.h +++ /dev/null @@ -1,8 +0,0 @@ - -#ifdef __CLING__ -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class ROOT::Math::RMinimizer+; -#endif diff --git a/math/rtools/inc/Math/RMinimizer.h b/math/rtools/inc/Math/RMinimizer.h deleted file mode 100644 index 63391c98f8cd6..0000000000000 --- a/math/rtools/inc/Math/RMinimizer.h +++ /dev/null @@ -1,89 +0,0 @@ -// Author: K. Hermansen and L. Moneta, Aug 2014 - -// Implementation file for class RMinimizer - -#ifndef ROOT_Math_RMinimizer -#define ROOT_Math_RMinimizer - -#include "Math/Functor.h" - -#include "Math/IParamFunctionfwd.h" - -#include "Math/BasicMinimizer.h" - -#include "TMatrixD.h" - -#include -#include - -namespace ROOT { - namespace Math{ - - /*! \brief RMinimizer class. - * - * Minimizer class that uses the ROOT/R interface to pass functions and minimize them in R. - * - * The class implements the ROOT::Math::Minimizer interface and can be instantiated using the - * ROOT plugin manager (plugin name is "RMinimizer"). The various minimization algorithms - * (BFGS, Nelder-Mead, SANN, etc..) can be passed as an option. - * The default algorithm is BFGS. - * - * The library for this and future R/ROOT classes is currently libRtools.so - */ - class RMinimizer : public ROOT::Math::BasicMinimizer { - protected: - std::string fMethod; /*!< minimizer method to be used, must be of a type listed in R optim or optimx descriptions */ - - private: - std::vector fErrors; /*!< vector of parameter errors */ - TMatrixD fCovMatrix; /*!< covariant matrix */ - TMatrixD fHessMatrix; /*!< Hessian matrix */ - - public: - /*! \brief Default constructor - * - * Default constructor with option for the method of minimization, can be any of the following: - *"Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN", "Brent" (Brent only for 1D minimization) - * - *See R optim or optimx descriptions for more details and options. - * - */ - RMinimizer(Option_t *method); - ///Destructor - ~RMinimizer() override {} - ///Function to find the minimum - bool Minimize() override; - ///Returns the number of function calls - unsigned int NCalls() const override; - ///Returns the ith jth component of the Hessian matrix - double HessMatrix(unsigned int i, unsigned int j) const; - /// minimizer provides error and error matrix - bool ProvidesError() const override { return !(fErrors.empty()); } - /// return errors at the minimum - const double * Errors() const override { return fErrors.data(); } - /** return covariance matrices element for variables ivar,jvar - if the variable is fixed the return value is zero - The ordering of the variables is the same as in the parameter and errors vectors - */ - double CovMatrix(unsigned int ivar , unsigned int jvar ) const override { - return fCovMatrix(ivar, jvar); - } - /** - Fill the passed array with the covariance matrix elements - if the variable is fixed or const the value is zero. - The array will be filled as cov[i *ndim + j] - The ordering of the variables is the same as in errors and parameter value. - This is different from the direct interface of Minuit2 or TMinuit where the - values were obtained only to variable parameters - */ - bool GetCovMatrix(double * covMat) const override { - int ndim = NDim(); - if (fCovMatrix.GetNrows() != ndim || fCovMatrix.GetNcols() != ndim ) return false; - std::copy(fCovMatrix.GetMatrixArray(), fCovMatrix.GetMatrixArray() + ndim*ndim, covMat); - return true; - } - }; - - } -} -#endif diff --git a/math/rtools/src/RMinimizer.cxx b/math/rtools/src/RMinimizer.cxx deleted file mode 100644 index 07d572b8d000f..0000000000000 --- a/math/rtools/src/RMinimizer.cxx +++ /dev/null @@ -1,182 +0,0 @@ - -#include "TRInterface.h" -#include "Math/RMinimizer.h" -#include "Math/IFunction.h" -#include -#include "Math/BasicMinimizer.h" - -namespace ROOT { - namespace Math{ - - /// function wrapper for the function to be minimized - const ROOT::Math::IMultiGenFunction *gFunction; - /// function wrapper for the gradient of the function to be minimized - const ROOT::Math::IMultiGradFunction *gGradFunction; - /// integer for the number of function calls - int gNCalls = 0; - - ///function to return the function values at point x - double minfunction(const std::vector & x){ - gNCalls++; - //return (*gFunction)(x.GetMatrixArray()); - return (*gFunction)(x.data()); - } - ///function to return the gradient values at point y - TVectorD mingradfunction(TVectorD y){ - unsigned int size = y.GetNoElements(); - const double * yy = y.GetMatrixArray(); - TVectorD zz(size); - gGradFunction->Gradient(yy,zz.data()); - return zz; - } - - /*Default constructor with option for the method of minimization, can be any of the following: - * - *"Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN", "Brent" (Brent only for 1D minimization) - */ - RMinimizer::RMinimizer(Option_t *method){ - fMethod=method; - if (fMethod.empty() || fMethod=="Migrad") fMethod="BFGS"; - } - - ///returns number of function calls - unsigned int RMinimizer::NCalls() const { return gNCalls; } - - ///function for finding the minimum - bool RMinimizer::Minimize() { - - //Set the functions - (gFunction)= ObjFunction(); - (gGradFunction) = GradObjFunction(); - - gNCalls = 0; - - //pass functions and variables to R - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - - 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()); - r["ndim"] = NDim(); - int ndim = NDim(); - r["stepsizes"] = stepSizes; - r["initialparams"] = values; - - //check if optimx is available - bool optimxloaded = FALSE; - r["optimxloaded"] = optimxloaded; - r.Execute("optimxloaded<-library(optimx,logical.return=TRUE)"); - //int ibool = r.ParseEval("optimxloaded").ToScalar(); - int ibool = r.Eval("optimxloaded"); - if (ibool==1) optimxloaded=kTRUE; - - //string for the command to be processed in R - TString cmd; - - //optimx is available and loaded - if (optimxloaded==kTRUE) { - if (!gGradFunction) { - // not using gradient function - cmd = TString::Format("result <- optimx( initialparams, minfunction,method='%s',control = list(ndeps=stepsizes,maxit=%d,trace=%d,abstol=%e),hessian=TRUE)",fMethod.c_str(),MaxIterations(),PrintLevel(),Tolerance()); - } - else { - // using user provided gradient - cmd = TString::Format("result <- optimx( initialparams, minfunction,mingradfunction, method='%s', control = list(ndeps=stepsizes,maxit=%d,trace=%d,abstol=%e),hessian=TRUE)",fMethod.c_str(),MaxIterations(),PrintLevel(),Tolerance()); - - } - } - - //optimx is not available - else { - if (!gGradFunction) { - // not using gradient function - cmd = TString::Format("result <- optim( initialparams, minfunction,method='%s',control = list(ndeps=stepsizes,maxit=%d,trace=%d,abstol=%e),hessian=TRUE)",fMethod.c_str(),MaxIterations(),PrintLevel(),Tolerance()); - } - else { - // using user provided gradient - cmd = TString::Format("result <- optim( initialparams, minfunction,mingradfunction, method='%s', control = list(ndeps=stepsizes,maxit=%d,trace=%d,abstol=%e),hessian=TRUE)",fMethod.c_str(),MaxIterations(),PrintLevel(),Tolerance()); - } - } - //execute the minimization in R - std::cout << "Calling R with command " << cmd << std::endl; - r.Execute(cmd.Data()); - - //results with optimx - if (optimxloaded){ - //get result from R - r.Execute("par<-coef(result)"); - //get hessian matrix (in list form) - r.Execute("hess<-attr(result,\"details\")[,\"nhatend\"]"); - //convert hess to a matrix - r.Execute("hess<-sapply(hess,function(x) x)"); - //convert to square matrix - r.Execute("hess<-matrix(hess,c(ndim,ndim))"); - //find covariant matrix from inverse of hess - r.Execute("cov<-solve(hess)"); - //get errors from the sqrt of the diagonal of cov - r.Execute("errors<-sqrt(abs(diag(cov)))"); - } - - //results with optim - else { - r.Execute("par<-result$par"); - r.Execute("hess<-result$hessian"); - r.Execute("cov<-solve(hess)"); - r.Execute("errors<-sqrt(abs(diag(cov)))"); - } - - //return the minimum to ROOT - //TVectorD vector = gR->ParseEval("par").ToVector(); - std::vector vectorPar = r["par"]; - - //get errors and matrices from R - // ROOT::R::TRObjectProxy p = gR->ParseEval("cov"); - // TMatrixD cm = p.ToMatrix(); - TMatrixD cm = r["cov"]; - // p = gR->ParseEval("errors"); - // TVectorD err = p.ToVector(); - std::vector err = r["errors"]; - // p = gR->ParseEval("hess"); - // TMatrixD hm = p.ToMatrix(); - TMatrixD hm = r["hess"]; - - //set covariant and Hessian matrices and error vector - fCovMatrix.ResizeTo(ndim,ndim); - fHessMatrix.ResizeTo(ndim,ndim); - //fErrors.ResizeTo(ndim); - fCovMatrix = cm; - fErrors = err; - fHessMatrix = hm; - - //get values and show minimum - const double *min=vectorPar.data(); - SetFinalValues(min); - SetMinValue((*gFunction)(min)); - std::cout<<"Value at minimum ="< ndim || j > ndim) return 0; - return fCovMatrix[i][j]; - } - // //Returns the full parameter error vector - // TVectorD RMinimizer::RErrors() const { - // return fErrors; - // } - //Returns the ith jth component of the Hessian matrix - double RMinimizer::HessMatrix(unsigned int i, unsigned int j) const { - unsigned int ndim = NDim(); - if (fHessMatrix==0) return 0; - if (i > ndim || j > ndim) return 0; - return fHessMatrix[i][j]; - } -#endif - } // end namespace MATH -} diff --git a/tmva/CMakeLists.txt b/tmva/CMakeLists.txt index ce18f6155ab90..52ebfc37749a9 100644 --- a/tmva/CMakeLists.txt +++ b/tmva/CMakeLists.txt @@ -14,11 +14,6 @@ if(tmva-pymva) add_subdirectory(pymva) endif() -# Build RMVA. Allows users to call R mva's from c++ ROOT/TMVA. -if(r OR tmva-rmva) - add_subdirectory(rmva) -endif() - add_subdirectory(sofie) #parser depends on protobuf #found if flag tmva-sofie is on diff --git a/tmva/rmva/CMakeLists.txt b/tmva/rmva/CMakeLists.txt deleted file mode 100644 index 4690d1417f02b..0000000000000 --- a/tmva/rmva/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. -# All rights reserved. -# -# For the licensing terms see $ROOTSYS/LICENSE. -# For the list of contributors see $ROOTSYS/README/CREDITS. - -############################################################################ -# CMakeLists.txt file for building ROOT R package -############################################################################ - -ROOT_STANDARD_LIBRARY_PACKAGE(RMVA - HEADERS - TMVA/MethodC50.h - TMVA/MethodRSNNS.h - TMVA/MethodRSVM.h - TMVA/MethodRXGB.h - TMVA/RMethodBase.h - SOURCES - src/MethodC50.cxx - src/MethodRSNNS.cxx - src/MethodRSVM.cxx - src/MethodRXGB.cxx - src/RMethodBase.cxx - DEPENDENCIES - Core - Matrix - RInterface - RIO - Thread - TMVA - NO_CXXMODULE -) diff --git a/tmva/rmva/inc/LinkDef.h b/tmva/rmva/inc/LinkDef.h deleted file mode 100644 index 78ead2d41b4c2..0000000000000 --- a/tmva/rmva/inc/LinkDef.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifdef __CLING__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; -#pragma link off all namespaces; - -#pragma link C++ nestedclass; - - -// the classifiers -#pragma link C++ class TMVA::RMethodBase+; -#pragma link C++ class TMVA::MethodC50+; -#pragma link C++ class TMVA::MethodRSNNS+; -#pragma link C++ class TMVA::MethodRSVM+; -#pragma link C++ class TMVA::MethodRXGB+; - -#endif - diff --git a/tmva/rmva/inc/TMVA/MethodC50.h b/tmva/rmva/inc/TMVA/MethodC50.h deleted file mode 100644 index 6ff16b12cb208..0000000000000 --- a/tmva/rmva/inc/TMVA/MethodC50.h +++ /dev/null @@ -1,117 +0,0 @@ -// @(#)root/tmva/rmva $Id$ -// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015 - -/********************************************************************************** - * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * - * Package: TMVA * - * Class : RMethodC50 * - * * - * Description: * - * R´s Package C50 method based on ROOTR * - * * - **********************************************************************************/ - -#ifndef ROOT_TMVA_RMethodC50 -#define ROOT_TMVA_RMethodC50 - -////////////////////////////////////////////////////////////////////////// -// // -// RMethodC50 // -// // -// // -////////////////////////////////////////////////////////////////////////// - -#include "TMVA/RMethodBase.h" -#include - -namespace TMVA { - - class Factory; // DSMTEST - class Reader; // DSMTEST - class DataSetManager; // DSMTEST - class Types; - class MethodC50 : public RMethodBase { - - public : - - // constructors - MethodC50(const TString &jobName, - const TString &methodTitle, - DataSetInfo &theData, - const TString &theOption = ""); - - MethodC50(DataSetInfo &dsi, - const TString &theWeightFile); - - - ~MethodC50(void); - void Train() override; - // options treatment - void Init() override; - void DeclareOptions() override; - void ProcessOptions() override; - // create ranking - const Ranking *CreateRanking() override - { - return nullptr; // = 0; - } - - - Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets) override; - - // performs classifier testing - void TestClassification() override; - - - Double_t GetMvaValue(Double_t *errLower = nullptr, Double_t *errUpper = nullptr) override; - void MakeClass(const TString &classFileName = TString("")) const override; //required for model persistence - using MethodBase::ReadWeightsFromStream; - // the actual "weights" - void AddWeightsXMLTo(void * /*parent*/) const override {} // = 0; - void ReadWeightsFromXML(void * /*weight*/) override {} // = 0; - void ReadWeightsFromStream(std::istream &) override {} //= 0; // backward compatibility - - // signal/background classification response for all current set of data - std::vector GetMvaValues(Long64_t firstEvt = 0, Long64_t lastEvt = -1, Bool_t logProgress = false) override; - - void ReadModelFromFile(); - private : - DataSetManager *fDataSetManager; // DSMTEST - friend class Factory; // DSMTEST - friend class Reader; // DSMTEST - protected: - //C5.0 function options - UInt_t fNTrials;//number of trials with boost enabled - Bool_t fRules;//A logical: should the tree be decomposed into a rule-based model? - - //Control options see C5.0Control - Bool_t fControlSubset; //A logical: should the model evaluate groups of discrete predictors for splits? - UInt_t fControlBands; - Bool_t fControlWinnow;// A logical: should predictor winnowing (i.e feature selection) be used? - Bool_t fControlNoGlobalPruning; //A logical to toggle whether the final, global pruning step to simplify the tree. - Double_t fControlCF; //A number in (0, 1) for the confidence factor. - UInt_t fControlMinCases;//an integer for the smallest number of samples that must be put in at least two of the splits. - Bool_t fControlFuzzyThreshold;//A logical toggle to evaluate possible advanced splits of the data. See Quinlan (1993) for details and examples. - Double_t fControlSample;//A value between (0, .999) that specifies the random proportion of the data should be used to train the model. - Int_t fControlSeed;//An integer for the random number seed within the C code. - Bool_t fControlEarlyStopping;// logical to toggle whether the internal method for stopping boosting should be used. - - UInt_t fMvaCounter; - static Bool_t IsModuleLoaded; - - ROOT::R::TRFunctionImport predict; - ROOT::R::TRFunctionImport C50; - ROOT::R::TRFunctionImport C50Control; - ROOT::R::TRFunctionImport asfactor; - ROOT::R::TRObject *fModel; - ROOT::R::TRObject fModelControl; - std::vector ListOfVariables; - - - // get help message text - void GetHelpMessage() const override; - - ClassDefOverride(MethodC50, 0) - }; -} // namespace TMVA -#endif diff --git a/tmva/rmva/inc/TMVA/MethodRSNNS.h b/tmva/rmva/inc/TMVA/MethodRSNNS.h deleted file mode 100644 index 61071fddd04a7..0000000000000 --- a/tmva/rmva/inc/TMVA/MethodRSNNS.h +++ /dev/null @@ -1,123 +0,0 @@ -// @(#)root/tmva/rmva $Id$ -// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015 - -/********************************************************************************** - * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * - * Package: TMVA * - * Class : RMethodRSNNS * - * * - * Description: * - * R´s Package RSNNS method based on ROOTR * - * * - **********************************************************************************/ - -#ifndef ROOT_TMVA_RMethodRSNNS -#define ROOT_TMVA_RMethodRSNNS - -////////////////////////////////////////////////////////////////////////// -// // -// RMethodRSNNS // -// // -// // -////////////////////////////////////////////////////////////////////////// - -#include "TMVA/RMethodBase.h" -#include - -namespace TMVA { - - class Factory; // DSMTEST - class Reader; // DSMTEST - class DataSetManager; // DSMTEST - class Types; - class MethodRSNNS : public RMethodBase { - - public : - - // constructors - MethodRSNNS(const TString &jobName, - const TString &methodTitle, - DataSetInfo &theData, - const TString &theOption = ""); - - MethodRSNNS(DataSetInfo &dsi, - const TString &theWeightFile); - - - ~MethodRSNNS(void); - void Train() override; - // options treatment - void Init() override; - void DeclareOptions() override; - void ProcessOptions() override; - // create ranking - const Ranking *CreateRanking() override - { - return nullptr; // = 0; - } - - - Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets) override; - - // performs classifier testing - void TestClassification() override; - - - Double_t GetMvaValue(Double_t *errLower = nullptr, Double_t *errUpper = nullptr) override; - - using MethodBase::ReadWeightsFromStream; - // the actual "weights" - void AddWeightsXMLTo(void * /*parent*/) const override {} // = 0; - void ReadWeightsFromXML(void * /*wghtnode*/) override {} // = 0; - void ReadWeightsFromStream(std::istream &) override {} //= 0; // backward compatibility - - void ReadModelFromFile(); - - // signal/background classification response for all current set of data - virtual std::vector GetMvaValues(Long64_t firstEvt = 0, Long64_t lastEvt = -1, Bool_t logProgress = false) override; - - private : - DataSetManager *fDataSetManager; // DSMTEST - friend class Factory; // DSMTEST - friend class Reader; // DSMTEST - protected: - UInt_t fMvaCounter; - std::vector fProbResultForTrainSig; - std::vector fProbResultForTestSig; - - TString fNetType;//default RMPL - //RSNNS Options for all NN methods - TString fSize;//number of units in the hidden layer(s) - UInt_t fMaxit;//maximum of iterations to learn - - TString fInitFunc;//the initialization function to use - TString fInitFuncParams;//the parameters for the initialization function (type 6 see getSnnsRFunctionTable() in RSNNS package) - - TString fLearnFunc;//the learning function to use - TString fLearnFuncParams;//the parameters for the learning function - - TString fUpdateFunc;//the update function to use - TString fUpdateFuncParams;//the parameters for the update function - - TString fHiddenActFunc;//the activation function of all hidden units - Bool_t fShufflePatterns;//should the patterns be shuffled? - Bool_t fLinOut;//sets the activation function of the output units to linear or logistic - - TString fPruneFunc;//the pruning function to use - TString fPruneFuncParams;//the parameters for the pruning function. Unlike the - //other functions, these have to be given in a named list. See - //the pruning demos for further explanation. - std::vector fFactorNumeric; //factors creations - //RSNNS mlp require a numeric factor then background=0 signal=1 from fFactorTrain - static Bool_t IsModuleLoaded; - ROOT::R::TRFunctionImport predict; - ROOT::R::TRFunctionImport mlp; - ROOT::R::TRFunctionImport asfactor; - ROOT::R::TRObject *fModel; - // get help message text - void GetHelpMessage() const override; - - ClassDefOverride(MethodRSNNS, 0) - }; -} // namespace TMVA -#endif diff --git a/tmva/rmva/inc/TMVA/MethodRSVM.h b/tmva/rmva/inc/TMVA/MethodRSVM.h deleted file mode 100644 index 2addd2f5ab253..0000000000000 --- a/tmva/rmva/inc/TMVA/MethodRSVM.h +++ /dev/null @@ -1,138 +0,0 @@ -// @(#)root/tmva/rmva $Id$ -// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015 - -/********************************************************************************** - * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * - * Package: TMVA * - * Class : RMethodRSVM * - * * - * Description: * - * R´s Package RSVM method based on ROOTR * - * * - **********************************************************************************/ - -#ifndef ROOT_TMVA_RMethodRSVM -#define ROOT_TMVA_RMethodRSVM - -////////////////////////////////////////////////////////////////////////// -// // -// RMethodRSVM // -// // -// // -////////////////////////////////////////////////////////////////////////// - -#include "TMVA/RMethodBase.h" -#include - -namespace TMVA { - - class Factory; // DSMTEST - class Reader; // DSMTEST - class DataSetManager; // DSMTEST - class Types; - class MethodRSVM : public RMethodBase { - - public : - - // constructors - MethodRSVM(const TString &jobName, - const TString &methodTitle, - DataSetInfo &theData, - const TString &theOption = ""); - - MethodRSVM(DataSetInfo &dsi, - const TString &theWeightFile); - - - ~MethodRSVM(void); - void Train() override; - // options treatment - void Init() override; - void DeclareOptions() override; - void ProcessOptions() override; - // create ranking - const Ranking *CreateRanking() override - { - return nullptr; // = 0; - } - - - Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets) override; - - // performs classifier testing - void TestClassification() override; - - - Double_t GetMvaValue(Double_t *errLower = nullptr, Double_t *errUpper = nullptr) override; - - using MethodBase::ReadWeightsFromStream; - // the actual "weights" - void AddWeightsXMLTo(void * /*parent*/) const override {} // = 0; - void ReadWeightsFromXML(void * /*wghtnode*/) override {} // = 0; - void ReadWeightsFromStream(std::istream &) override {} //= 0; // backward compatibility - void ReadModelFromFile(); - - // signal/background classification response for all current set of data - std::vector GetMvaValues(Long64_t firstEvt = 0, Long64_t lastEvt = -1, Bool_t logProgress = false) override; - - private : - DataSetManager *fDataSetManager; // DSMTEST - friend class Factory; // DSMTEST - friend class Reader; // DSMTEST - protected: - UInt_t fMvaCounter; - std::vector fProbResultForTrainSig; - std::vector fProbResultForTestSig; - - //Booking options - Bool_t fScale;//A logical vector indicating the variables to be scaled. If - //‘scale’ is of length 1, the value is recycled as many times - //as needed. Per default, data are scaled internally (both ‘x’ - //and ‘y’ variables) to zero mean and unit variance. The center - //and scale values are returned and used for later predictions. - TString fType;//‘svm’ can be used as a classification machine, as a - //regression machine, or for novelty detection. Depending of - //whether ‘y’ is a factor or not, the default setting for - //‘type’ is ‘C-classification’ or ‘eps-regression’, - //respectively, but may be overwritten by setting an explicit value. - //Valid options are: - // - ‘C-classification’ - // - ‘nu-classification’ - // - ‘one-classification’ (for novelty detection) - // - ‘eps-regression’ - // - ‘nu-regression’ - TString fKernel;//the kernel used in training and predicting. You might - //consider changing some of the following parameters, depending on the kernel type. - //linear: u'*v - //polynomial: (gamma*u'*v + coef0)^degree - //radial basis: exp(-gamma*|u-v|^2) - //sigmoid: tanh(gamma*u'*v + coef0) - Int_t fDegree;//parameter needed for kernel of type ‘polynomial’ (default: 3) - Float_t fGamma;//parameter needed for all kernels except ‘linear’ (default: 1/(data dimension)) - Float_t fCoef0;//parameter needed for kernels of type ‘polynomial’ and ‘sigmoid’ (default: 0) - Float_t fCost;//cost of constraints violation (default: 1)-it is the - //‘C’-constant of the regularization term in the Lagrange formulation. - Float_t fNu;//parameter needed for ‘nu-classification’, ‘nu-regression’, and ‘one-classification’ - Float_t fCacheSize;//cache memory in MB (default 40) - Float_t fTolerance;//tolerance of termination criterion (default: 0.001) - Float_t fEpsilon;//epsilon in the insensitive-loss function (default: 0.1) - Bool_t fShrinking;//option whether to use the shrinking-heuristics (default: ‘TRUE’) - Float_t fCross;//if a integer value k>0 is specified, a k-fold cross - //validation on the training data is performed to assess the - //quality of the model: the accuracy rate for classification - //and the Mean Squared Error for regression - Bool_t fProbability;//logical indicating whether the model should allow for probability predictions. - Bool_t fFitted;//logical indicating whether the fitted values should be computed and included in the model or not (default: ‘TRUE’) - - static Bool_t IsModuleLoaded; - ROOT::R::TRFunctionImport svm; - ROOT::R::TRFunctionImport predict; - ROOT::R::TRFunctionImport asfactor; - ROOT::R::TRObject *fModel; - // get help message text - void GetHelpMessage() const override; - - ClassDefOverride(MethodRSVM, 0) - }; -} // namespace TMVA -#endif diff --git a/tmva/rmva/inc/TMVA/MethodRXGB.h b/tmva/rmva/inc/TMVA/MethodRXGB.h deleted file mode 100644 index 35c0f7e75ef2d..0000000000000 --- a/tmva/rmva/inc/TMVA/MethodRXGB.h +++ /dev/null @@ -1,112 +0,0 @@ -// @(#)root/tmva/rmva $Id$ -// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015 - -/********************************************************************************** - * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * - * Package: TMVA * - * Class : RMethodRXGB * - * * - * Description: * - * R´s Package xgboost method based on ROOTR * - * * - **********************************************************************************/ - -#ifndef ROOT_TMVA_RMethodXGB -#define ROOT_TMVA_RMethodXGB - -////////////////////////////////////////////////////////////////////////// -// // -// RMethodRXGB // -// // -// // -////////////////////////////////////////////////////////////////////////// - -#include "TMVA/RMethodBase.h" -#include - -namespace TMVA { - - class Factory; // DSMTEST - class Reader; // DSMTEST - class DataSetManager; // DSMTEST - class Types; - class MethodRXGB: public RMethodBase { - - public : - - // constructors - MethodRXGB(const TString &jobName, - const TString &methodTitle, - DataSetInfo &theData, - const TString &theOption = ""); - - MethodRXGB(DataSetInfo &dsi, - const TString &theWeightFile); - - - ~MethodRXGB(void); - void Train() override; - // options treatment - void Init() override; - void DeclareOptions() override; - void ProcessOptions() override; - // create ranking - const Ranking *CreateRanking() override - { - return nullptr; // = 0; - } - - - Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets) override; - - // performs classifier testing - void TestClassification() override; - - - Double_t GetMvaValue(Double_t *errLower = nullptr, Double_t *errUpper = nullptr) override; - void MakeClass(const TString &classFileName = TString("")) const override; //required for model persistence - using MethodBase::ReadWeightsFromStream; - // the actual "weights" - void AddWeightsXMLTo(void * /*parent*/) const override {} // = 0; - void ReadWeightsFromXML(void * /*wghtnode*/) override {} // = 0; - void ReadWeightsFromStream(std::istream &) override {} //= 0; // backward compatibility - - void ReadModelFromFile(); - - // signal/background classification response for all current set of data - std::vector GetMvaValues(Long64_t firstEvt = 0, Long64_t lastEvt = -1, Bool_t logProgress = false) override; - - private : - DataSetManager *fDataSetManager; // DSMTEST - friend class Factory; // DSMTEST - friend class Reader; // DSMTEST - protected: - - - //RXGBfunction options - //https://github.com/dmlc/xgboost/blob/master/doc/parameter.md - UInt_t fNRounds; - Double_t fEta; - UInt_t fMaxDepth; - static Bool_t IsModuleLoaded; - - std::vector fFactorNumeric; //factors creations - //xgboost require a numeric factor then background=0 signal=1 from fFactorTrain - - ROOT::R::TRFunctionImport predict; - ROOT::R::TRFunctionImport xgbtrain; - ROOT::R::TRFunctionImport xgbdmatrix; - ROOT::R::TRFunctionImport xgbsave; - ROOT::R::TRFunctionImport xgbload; - ROOT::R::TRFunctionImport asfactor; - ROOT::R::TRFunctionImport asmatrix; - ROOT::R::TRObject *fModel; - - - // get help message text - void GetHelpMessage() const override; - - ClassDefOverride(MethodRXGB, 0) - }; -} // namespace TMVA -#endif diff --git a/tmva/rmva/inc/TMVA/RMethodBase.h b/tmva/rmva/inc/TMVA/RMethodBase.h deleted file mode 100644 index 072b1e2e13896..0000000000000 --- a/tmva/rmva/inc/TMVA/RMethodBase.h +++ /dev/null @@ -1,87 +0,0 @@ -// @(#)root/tmva/rmva $Id$ -// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015 - -/********************************************************************************** - * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * - * Package: TMVA * - * Class : RMethodBase * - * * - * Description: * - * Virtual base class for all MVA method based on ROOTR * - * * - **********************************************************************************/ - -#ifndef ROOT_TMVA_RMethodBase -#define ROOT_TMVA_RMethodBase - -////////////////////////////////////////////////////////////////////////// -// // -// RMethodBase // -// // -// Virtual base class for all TMVA method based on ROOTR // -// // -////////////////////////////////////////////////////////////////////////// - -#include "TMVA/MethodBase.h" - -#include - -#include -#include - -class TGraph; -class TTree; -class TDirectory; -class TSpline; -class TH1F; -class TH1D; - -namespace TMVA { - - class Ranking; - class PDF; - class TSpline1; - class MethodCuts; - class MethodBoost; - class DataSetInfo; - - class RMethodBase : public MethodBase { - - friend class Factory; - protected: - ROOT::R::TRInterface &r; - public: - - // default constructur - RMethodBase(const TString &jobName, - Types::EMVA methodType, - const TString &methodTitle, - DataSetInfo &dsi, - const TString &theOption = "", ROOT::R::TRInterface &_r = ROOT::R::TRInterface::Instance()); - - // constructor used for Testing + Application of the MVA, only (no training), - // using given weight file - RMethodBase(Types::EMVA methodType, - DataSetInfo &dsi, - const TString &weightFile, ROOT::R::TRInterface &_r = ROOT::R::TRInterface::Instance()); - protected: - - void LoadData();//Read data from Data() Aand DataInfo() to Dataframes and Vectors - protected: - ROOT::R::TRDataFrame fDfTrain;//signal and backgrd - ROOT::R::TRDataFrame fDfTest; - TVectorD fWeightTrain; - TVectorD fWeightTest; - std::vector fFactorTrain; - std::vector fFactorTest; - ROOT::R::TRDataFrame fDfSpectators; - - private: - ClassDefOverride(RMethodBase, 0) // Virtual base class for all TMVA method - - }; -} // namespace TMVA - -#endif - - diff --git a/tmva/rmva/src/MethodC50.cxx b/tmva/rmva/src/MethodC50.cxx deleted file mode 100644 index 40b0454fa8aa7..0000000000000 --- a/tmva/rmva/src/MethodC50.cxx +++ /dev/null @@ -1,340 +0,0 @@ -// @(#)root/tmva/rmva $Id$ -// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015 - -/********************************************************************************** - * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * - * Package: TMVA * - * Class : MethodC50 * - * Web : http://oproject.org * - * * - * Description: * - * Decision Trees and Rule-Based Models * - * * - * * - * Redistribution and use in source and binary forms, with or without * - * modification, are permitted according to the terms listed in LICENSE * - * (see tmva/doc/LICENSE) * - * * - **********************************************************************************/ - -#include - -#include "TMath.h" -#include "Riostream.h" -#include "TMatrix.h" -#include "TMatrixD.h" -#include "TVectorD.h" - -#include "TMVA/VariableTransformBase.h" -#include "TMVA/MethodC50.h" -#include "TMVA/Tools.h" -#include "TMVA/Config.h" -#include "TMVA/Ranking.h" -#include "TMVA/Types.h" -#include "TMVA/PDF.h" -#include "TMVA/ClassifierFactory.h" - -#include "TMVA/Results.h" -#include "TMVA/Timer.h" - -using namespace TMVA; - -REGISTER_METHOD(C50) - - -//creating an Instance -Bool_t MethodC50::IsModuleLoaded = ROOT::R::TRInterface::Instance().Require("C50"); - -//_______________________________________________________________________ -MethodC50::MethodC50(const TString &jobName, - const TString &methodTitle, - DataSetInfo &dsi, - const TString &theOption) : RMethodBase(jobName, Types::kC50, methodTitle, dsi, theOption), - fNTrials(1), - fRules(kFALSE), - fMvaCounter(0), - predict("predict.C5.0"), - //predict("predict"), - C50("C5.0"), - C50Control("C5.0Control"), - asfactor("as.factor"), - fModel(NULL) -{ - // standard constructor for the C50 - - //C5.0Control options - fControlSubset = kTRUE; - fControlBands = 0; - fControlWinnow = kFALSE; - fControlNoGlobalPruning = kFALSE; - fControlCF = 0.25; - fControlMinCases = 2; - fControlFuzzyThreshold = kFALSE; - fControlSample = 0; - r["sample.int(4096, size = 1) - 1L"] >> fControlSeed; - fControlEarlyStopping = kTRUE; - - ListOfVariables = DataInfo().GetListOfVariables(); -} - -//_______________________________________________________________________ -MethodC50::MethodC50(DataSetInfo &theData, const TString &theWeightFile) - : RMethodBase(Types::kC50, theData, theWeightFile), - fNTrials(1), - fRules(kFALSE), - fMvaCounter(0), - predict("predict.C5.0"), - C50("C5.0"), - C50Control("C5.0Control"), - asfactor("as.factor"), - fModel(NULL) -{ - - // constructor from weight file - fControlSubset = kTRUE; - fControlBands = 0; - fControlWinnow = kFALSE; - fControlNoGlobalPruning = kFALSE; - fControlCF = 0.25; - fControlMinCases = 2; - fControlFuzzyThreshold = kFALSE; - fControlSample = 0; - r["sample.int(4096, size = 1) - 1L"] >> fControlSeed; - fControlEarlyStopping = kTRUE; -} - - -//_______________________________________________________________________ -MethodC50::~MethodC50(void) -{ - if (fModel) delete fModel; -} - -//_______________________________________________________________________ -Bool_t MethodC50::HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t /*numberTargets*/) -{ - if (type == Types::kClassification && numberClasses == 2) return kTRUE; - return kFALSE; -} - - -//_______________________________________________________________________ -void MethodC50::Init() -{ - - if (!IsModuleLoaded) { - Error("Init", "R's package C50 can not be loaded."); - Log() << kFATAL << " R's package C50 can not be loaded." - << Endl; - return; - } -} - -void MethodC50::Train() -{ - if (Data()->GetNTrainingEvents() == 0) Log() << kFATAL << " Data() has zero events" << Endl; - SEXP Model = C50(ROOT::R::Label["x"] = fDfTrain, \ - ROOT::R::Label["y"] = asfactor(fFactorTrain), \ - ROOT::R::Label["trials"] = fNTrials, \ - ROOT::R::Label["rules"] = fRules, \ - ROOT::R::Label["weights"] = fWeightTrain, \ - ROOT::R::Label["control"] = fModelControl); - fModel = new ROOT::R::TRObject(Model); - if (IsModelPersistence()) - { - TString path = GetWeightFileDir() + "/" + GetName() + ".RData"; - Log() << Endl; - Log() << gTools().Color("bold") << "--- Saving State File In:" << gTools().Color("reset") << path << Endl; - Log() << Endl; - r["C50Model"] << Model; - r << "save(C50Model,file='" + path + "')"; - } -} - -//_______________________________________________________________________ -void MethodC50::DeclareOptions() -{ - // - DeclareOptionRef(fNTrials, "NTrials", "An integer specifying the number of boosting iterations"); - DeclareOptionRef(fRules, "Rules", "A logical: should the tree be decomposed into a rule-basedmodel?"); - - //C5.0Control Options - DeclareOptionRef(fControlSubset, "ControlSubset", "A logical: should the model evaluate groups of discrete \ - predictors for splits? Note: the C5.0 command line version defaults this \ - parameter to ‘FALSE’, meaning no attempted gropings will be evaluated \ - during the tree growing stage."); - DeclareOptionRef(fControlBands, "ControlBands", "An integer between 2 and 1000. If ‘TRUE’, the model orders \ - the rules by their affect on the error rate and groups the \ - rules into the specified number of bands. This modifies the \ - output so that the effect on the error rate can be seen for \ - the groups of rules within a band. If this options is \ - selected and ‘rules = kFALSE’, a warning is issued and ‘rules’ \ - is changed to ‘kTRUE’."); - DeclareOptionRef(fControlWinnow, "ControlWinnow", "A logical: should predictor winnowing (i.e feature selection) be used?"); - DeclareOptionRef(fControlNoGlobalPruning, "ControlNoGlobalPruning", "A logical to toggle whether the final, global pruning \ - step to simplify the tree."); - DeclareOptionRef(fControlCF, "ControlCF", "A number in (0, 1) for the confidence factor."); - DeclareOptionRef(fControlMinCases, "ControlMinCases", "an integer for the smallest number of samples that must be \ - put in at least two of the splits."); - - DeclareOptionRef(fControlFuzzyThreshold, "ControlFuzzyThreshold", "A logical toggle to evaluate possible advanced splits \ - of the data. See Quinlan (1993) for details and examples."); - DeclareOptionRef(fControlSample, "ControlSample", "A value between (0, .999) that specifies the random \ - proportion of the data should be used to train the model. By \ - default, all the samples are used for model training. Samples \ - not used for training are used to evaluate the accuracy of \ - the model in the printed output."); - DeclareOptionRef(fControlSeed, "ControlSeed", " An integer for the random number seed within the C code."); - DeclareOptionRef(fControlEarlyStopping, "ControlEarlyStopping", " A logical to toggle whether the internal method for \ - stopping boosting should be used."); - - -} - -//_______________________________________________________________________ -void MethodC50::ProcessOptions() -{ - if (fNTrials <= 0) { - Log() << kERROR << " fNTrials <=0... that does not work !! " - << " I set it to 1 .. just so that the program does not crash" - << Endl; - fNTrials = 1; - } - fModelControl = C50Control(ROOT::R::Label["subset"] = fControlSubset, \ - ROOT::R::Label["bands"] = fControlBands, \ - ROOT::R::Label["winnow"] = fControlWinnow, \ - ROOT::R::Label["noGlobalPruning"] = fControlNoGlobalPruning, \ - ROOT::R::Label["CF"] = fControlCF, \ - ROOT::R::Label["minCases"] = fControlMinCases, \ - ROOT::R::Label["fuzzyThreshold"] = fControlFuzzyThreshold, \ - ROOT::R::Label["sample"] = fControlSample, \ - ROOT::R::Label["seed"] = fControlSeed, \ - ROOT::R::Label["earlyStopping"] = fControlEarlyStopping); -} - -//_______________________________________________________________________ -void MethodC50::TestClassification() -{ - Log() << kINFO << "Testing Classification C50 METHOD " << Endl; - MethodBase::TestClassification(); -} - - -//_______________________________________________________________________ -Double_t MethodC50::GetMvaValue(Double_t *errLower, Double_t *errUpper) -{ - NoErrorCalc(errLower, errUpper); - Double_t mvaValue; - const TMVA::Event *ev = GetEvent(); - const UInt_t nvar = DataInfo().GetNVariables(); - ROOT::R::TRDataFrame fDfEvent; - for (UInt_t i = 0; i < nvar; i++) { - fDfEvent[DataInfo().GetListOfVariables()[i].Data()] = ev->GetValues()[i]; - } - //if using persistence model - if (IsModelPersistence()) ReadStateFromFile(); - - TVectorD result = predict(*fModel, fDfEvent, ROOT::R::Label["type"] = "prob"); - mvaValue = result[1]; //returning signal prob - return mvaValue; -} - - -//////////////////////////////////////////////////////////////////////////////// -/// get all the MVA values for the events of the current Data type -std::vector MethodC50::GetMvaValues(Long64_t firstEvt, Long64_t lastEvt, Bool_t logProgress) -{ - Long64_t nEvents = Data()->GetNEvents(); - if (firstEvt > lastEvt || lastEvt > nEvents) lastEvt = nEvents; - if (firstEvt < 0) firstEvt = 0; - - nEvents = lastEvt-firstEvt; - - UInt_t nvars = Data()->GetNVariables(); - - // use timer - Timer timer( nEvents, GetName(), kTRUE ); - if (logProgress) - Log() << kINFO<GetCurrentType()==Types::kTraining?"training":"testing") << " sample (" << nEvents << " events)" << Endl; - - - // fill R DATA FRAME with events data - std::vector > inputData(nvars); - for (UInt_t i = 0; i < nvars; i++) { - inputData[i] = std::vector(nEvents); - } - - for (Int_t ievt=firstEvt; ievtSetCurrentEvent(ievt); - const TMVA::Event *e = Data()->GetEvent(); - assert(nvars == e->GetNVariables()); - for (UInt_t i = 0; i < nvars; i++) { - inputData[i][ievt] = e->GetValue(i); - } - // if (ievt%100 == 0) - // std::cout << "Event " << ievt << " type" << DataInfo().IsSignal(e) << " : " << pValue[ievt*nvars] << " " << pValue[ievt*nvars+1] << " " << pValue[ievt*nvars+2] << std::endl; - } - - ROOT::R::TRDataFrame evtData; - for (UInt_t i = 0; i < nvars; i++) { - evtData[DataInfo().GetListOfVariables()[i].Data()] = inputData[i]; - } - //if using persistence model - if (IsModelPersistence()) ReadModelFromFile(); - - std::vector mvaValues(nEvents); - ROOT::R::TRObject result = predict(*fModel, evtData, ROOT::R::Label["type"] = "prob"); - std::vector probValues(2*nEvents); - probValues = result.As>(); - assert(probValues.size() == 2*mvaValues.size()); - std::copy(probValues.begin()+nEvents, probValues.end(), mvaValues.begin() ); - - if (logProgress) { - Log() << kINFO <" << Endl; -} - -//_______________________________________________________________________ -void TMVA::MethodC50::ReadModelFromFile() -{ - ROOT::R::TRInterface::Instance().Require("C50"); - TString path = GetWeightFileDir() + "/" + GetName() + ".RData"; - Log() << Endl; - Log() << gTools().Color("bold") << "--- Loading State File From:" << gTools().Color("reset") << path << Endl; - Log() << Endl; - r << "load('" + path + "')"; - SEXP Model; - r["C50Model"] >> Model; - fModel = new ROOT::R::TRObject(Model); - -} - -//_______________________________________________________________________ -void TMVA::MethodC50::MakeClass(const TString &/*theClassFileName*/) const -{ -} diff --git a/tmva/rmva/src/MethodRSNNS.cxx b/tmva/rmva/src/MethodRSNNS.cxx deleted file mode 100644 index 321cf6d06ff23..0000000000000 --- a/tmva/rmva/src/MethodRSNNS.cxx +++ /dev/null @@ -1,365 +0,0 @@ -// @(#)root/tmva/rmva $Id$ -// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015 - - -/********************************************************************************** - * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * - * Package: TMVA * - * Class : MethodRSNNS * - * Web : http://oproject.org * - * * - * Description: * - * Neural Networks in R using the Stuttgart Neural Network Simulator * - * * - * * - * Redistribution and use in source and binary forms, with or without * - * modification, are permitted according to the terms listed in LICENSE * - * (see tmva/doc/LICENSE) * - * * - **********************************************************************************/ - -#include - -#include "TMath.h" -#include "Riostream.h" -#include "TMatrix.h" -#include "TMatrixD.h" -#include "TVectorD.h" - -#include "TMVA/VariableTransformBase.h" -#include "TMVA/MethodRSNNS.h" -#include "TMVA/Tools.h" -#include "TMVA/Config.h" -#include "TMVA/Ranking.h" -#include "TMVA/Types.h" -#include "TMVA/PDF.h" -#include "TMVA/ClassifierFactory.h" - -#include "TMVA/Results.h" -#include "TMVA/Timer.h" - -using namespace TMVA; - -REGISTER_METHOD(RSNNS) - - -//creating an Instance -Bool_t MethodRSNNS::IsModuleLoaded = ROOT::R::TRInterface::Instance().Require("RSNNS"); - -//_______________________________________________________________________ -MethodRSNNS::MethodRSNNS(const TString &jobName, - const TString &methodTitle, - DataSetInfo &dsi, - const TString &theOption) : - RMethodBase(jobName, Types::kRSNNS, methodTitle, dsi, theOption), - fMvaCounter(0), - predict("predict"), - mlp("mlp"), - asfactor("as.factor"), - fModel(NULL) -{ - fNetType = methodTitle; - if (fNetType != "RMLP") { - Log() << kFATAL << " Unknow Method" + fNetType - << Endl; - return; - } - - // standard constructor for the RSNNS - //RSNNS Options for all NN methods - fSize = "c(5)"; - fMaxit = 100; - - fInitFunc = "Randomize_Weights"; - fInitFuncParams = "c(-0.3,0.3)"; //the maximun number of pacameter is 5 see RSNNS::getSnnsRFunctionTable() type 6 - - fLearnFunc = "Std_Backpropagation"; // - fLearnFuncParams = "c(0.2,0)"; - - fUpdateFunc = "Topological_Order"; - fUpdateFuncParams = "c(0)"; - - fHiddenActFunc = "Act_Logistic"; - fShufflePatterns = kTRUE; - fLinOut = kFALSE; - fPruneFunc = "NULL"; - fPruneFuncParams = "NULL"; - -} - -//_______________________________________________________________________ -MethodRSNNS::MethodRSNNS(DataSetInfo &theData, const TString &theWeightFile) - : RMethodBase(Types::kRSNNS, theData, theWeightFile), - fMvaCounter(0), - predict("predict"), - mlp("mlp"), - asfactor("as.factor"), - fModel(NULL) - -{ - fNetType = "RMLP"; //GetMethodName();//GetMethodName() is not returning RMLP is reting MethodBase why? - if (fNetType != "RMLP") { - Log() << kFATAL << " Unknow Method = " + fNetType - << Endl; - return; - } - - // standard constructor for the RSNNS - //RSNNS Options for all NN methods - fSize = "c(5)"; - fMaxit = 100; - - fInitFunc = "Randomize_Weights"; - fInitFuncParams = "c(-0.3,0.3)"; //the maximun number of pacameter is 5 see RSNNS::getSnnsRFunctionTable() type 6 - - fLearnFunc = "Std_Backpropagation"; // - fLearnFuncParams = "c(0.2,0)"; - - fUpdateFunc = "Topological_Order"; - fUpdateFuncParams = "c(0)"; - - fHiddenActFunc = "Act_Logistic"; - fShufflePatterns = kTRUE; - fLinOut = kFALSE; - fPruneFunc = "NULL"; - fPruneFuncParams = "NULL"; -} - - -//_______________________________________________________________________ -MethodRSNNS::~MethodRSNNS(void) -{ - if (fModel) delete fModel; -} - -//_______________________________________________________________________ -Bool_t MethodRSNNS::HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t /*numberTargets*/) -{ - if (type == Types::kClassification && numberClasses == 2) return kTRUE; - return kFALSE; -} - - -//_______________________________________________________________________ -void MethodRSNNS::Init() -{ - if (!IsModuleLoaded) { - Error("Init", "R's package RSNNS can not be loaded."); - Log() << kFATAL << " R's package RSNNS can not be loaded." - << Endl; - return; - } - //factors creations - //RSNNS mlp require a numeric factor then background=0 signal=1 from fFactorTrain/fFactorTest - UInt_t size = fFactorTrain.size(); - fFactorNumeric.resize(size); - - for (UInt_t i = 0; i < size; i++) { - if (fFactorTrain[i] == "signal") fFactorNumeric[i] = 1; - else fFactorNumeric[i] = 0; - } -} - -void MethodRSNNS::Train() -{ - if (Data()->GetNTrainingEvents() == 0) Log() << kFATAL << " Data() has zero events" << Endl; - if (fNetType == "RMLP") { - ROOT::R::TRObject PruneFunc; - if (fPruneFunc == "NULL") PruneFunc = r.Eval("NULL"); - else PruneFunc = r.Eval(Form("'%s'", fPruneFunc.Data())); - - SEXP Model = mlp(ROOT::R::Label["x"] = fDfTrain, - ROOT::R::Label["y"] = fFactorNumeric, - ROOT::R::Label["size"] = r.Eval(fSize), - ROOT::R::Label["maxit"] = fMaxit, - ROOT::R::Label["initFunc"] = fInitFunc, - ROOT::R::Label["initFuncParams"] = r.Eval(fInitFuncParams), - ROOT::R::Label["learnFunc"] = fLearnFunc, - ROOT::R::Label["learnFuncParams"] = r.Eval(fLearnFuncParams), - ROOT::R::Label["updateFunc"] = fUpdateFunc, - ROOT::R::Label["updateFuncParams"] = r.Eval(fUpdateFuncParams), - ROOT::R::Label["hiddenActFunc"] = fHiddenActFunc, - ROOT::R::Label["shufflePatterns"] = fShufflePatterns, - ROOT::R::Label["libOut"] = fLinOut, - ROOT::R::Label["pruneFunc"] = PruneFunc, - ROOT::R::Label["pruneFuncParams"] = r.Eval(fPruneFuncParams)); - fModel = new ROOT::R::TRObject(Model); - //if model persistence is enabled saving it is R serialziation. - if (IsModelPersistence()) - { - TString path = GetWeightFileDir() + "/" + GetName() + ".RData"; - Log() << Endl; - Log() << gTools().Color("bold") << "--- Saving State File In:" << gTools().Color("reset") << path << Endl; - Log() << Endl; - r["RMLPModel"] << Model; - r << "save(RMLPModel,file='" + path + "')"; - } - } -} - -//_______________________________________________________________________ -void MethodRSNNS::DeclareOptions() -{ - //RSNNS Options for all NN methods -// TVectorF fSize;//number of units in the hidden layer(s) - DeclareOptionRef(fSize, "Size", "number of units in the hidden layer(s)"); - DeclareOptionRef(fMaxit, "Maxit", "Maximum of iterations to learn"); - - DeclareOptionRef(fInitFunc, "InitFunc", "the initialization function to use"); - DeclareOptionRef(fInitFuncParams, "InitFuncParams", "the parameters for the initialization function"); - - DeclareOptionRef(fLearnFunc, "LearnFunc", "the learning function to use"); - DeclareOptionRef(fLearnFuncParams, "LearnFuncParams", "the parameters for the learning function"); - - DeclareOptionRef(fUpdateFunc, "UpdateFunc", "the update function to use"); - DeclareOptionRef(fUpdateFuncParams, "UpdateFuncParams", "the parameters for the update function"); - - DeclareOptionRef(fHiddenActFunc, "HiddenActFunc", "the activation function of all hidden units"); - DeclareOptionRef(fShufflePatterns, "ShufflePatterns", "should the patterns be shuffled?"); - DeclareOptionRef(fLinOut, "LinOut", "sets the activation function of the output units to linear or logistic"); - - DeclareOptionRef(fPruneFunc, "PruneFunc", "the prune function to use"); - DeclareOptionRef(fPruneFuncParams, "PruneFuncParams", "the parameters for the pruning function. Unlike the\ - other functions, these have to be given in a named list. See\ - the pruning demos for further explanation.the update function to use"); - -} - -//_______________________________________________________________________ -void MethodRSNNS::ProcessOptions() -{ - if (fMaxit <= 0) { - Log() << kERROR << " fMaxit <=0... that does not work !! " - << " I set it to 50 .. just so that the program does not crash" - << Endl; - fMaxit = 1; - } - // standard constructor for the RSNNS - //RSNNS Options for all NN methods - -} - -//_______________________________________________________________________ -void MethodRSNNS::TestClassification() -{ - Log() << kINFO << "Testing Classification " << fNetType << " METHOD " << Endl; - - MethodBase::TestClassification(); -} - - -//_______________________________________________________________________ -Double_t MethodRSNNS::GetMvaValue(Double_t *errLower, Double_t *errUpper) -{ - NoErrorCalc(errLower, errUpper); - Double_t mvaValue; - const TMVA::Event *ev = GetEvent(); - const UInt_t nvar = DataInfo().GetNVariables(); - ROOT::R::TRDataFrame fDfEvent; - for (UInt_t i = 0; i < nvar; i++) { - fDfEvent[DataInfo().GetListOfVariables()[i].Data()] = ev->GetValues()[i]; - } - //if using persistence model - if (IsModelPersistence()) ReadModelFromFile(); - - TVectorD result = predict(*fModel, fDfEvent, ROOT::R::Label["type"] = "prob"); - mvaValue = result[0]; //returning signal prob - return mvaValue; -} - -//////////////////////////////////////////////////////////////////////////////// -/// get all the MVA values for the events of the current Data type -std::vector MethodRSNNS::GetMvaValues(Long64_t firstEvt, Long64_t lastEvt, Bool_t logProgress) -{ - Long64_t nEvents = Data()->GetNEvents(); - if (firstEvt > lastEvt || lastEvt > nEvents) lastEvt = nEvents; - if (firstEvt < 0) firstEvt = 0; - - nEvents = lastEvt-firstEvt; - - UInt_t nvars = Data()->GetNVariables(); - - // use timer - Timer timer( nEvents, GetName(), kTRUE ); - if (logProgress) - Log() << kINFO<GetCurrentType()==Types::kTraining?"training":"testing") << " sample (" << nEvents << " events)" << Endl; - - - // fill R DATA FRAME with events data - std::vector > inputData(nvars); - for (UInt_t i = 0; i < nvars; i++) { - inputData[i] = std::vector(nEvents); - } - - for (Int_t ievt=firstEvt; ievtSetCurrentEvent(ievt); - const TMVA::Event *e = Data()->GetEvent(); - assert(nvars == e->GetNVariables()); - for (UInt_t i = 0; i < nvars; i++) { - inputData[i][ievt] = e->GetValue(i); - } - // if (ievt%100 == 0) - // std::cout << "Event " << ievt << " type" << DataInfo().IsSignal(e) << " : " << pValue[ievt*nvars] << " " << pValue[ievt*nvars+1] << " " << pValue[ievt*nvars+2] << std::endl; - } - - ROOT::R::TRDataFrame evtData; - for (UInt_t i = 0; i < nvars; i++) { - evtData[DataInfo().GetListOfVariables()[i].Data()] = inputData[i]; - } - //if using persistence model - if (IsModelPersistence()) ReadModelFromFile(); - - std::vector mvaValues(nEvents); - ROOT::R::TRObject result = predict(*fModel, evtData, ROOT::R::Label["type"] = "prob"); - //std::vector probValues(2*nEvents); - mvaValues = result.As>(); - // assert(probValues.size() == 2*mvaValues.size()); - // std::copy(probValues.begin()+nEvents, probValues.end(), mvaValues.begin() ); - - if (logProgress) { - Log() << kINFO <> Model; - fModel = new ROOT::R::TRObject(Model); - -} - - -//_______________________________________________________________________ -void MethodRSNNS::GetHelpMessage() const -{ -// get help message text -// -// typical length of text line: -// "|--------------------------------------------------------------|" - Log() << Endl; - Log() << gTools().Color("bold") << "--- Short description:" << gTools().Color("reset") << Endl; - Log() << Endl; - Log() << "Decision Trees and Rule-Based Models " << Endl; - Log() << Endl; - Log() << gTools().Color("bold") << "--- Performance optimisation:" << gTools().Color("reset") << Endl; - Log() << Endl; - Log() << Endl; - Log() << gTools().Color("bold") << "--- Performance tuning via configuration options:" << gTools().Color("reset") << Endl; - Log() << Endl; - Log() << "" << Endl; -} - diff --git a/tmva/rmva/src/MethodRSVM.cxx b/tmva/rmva/src/MethodRSVM.cxx deleted file mode 100644 index 4129fdcb3d8c3..0000000000000 --- a/tmva/rmva/src/MethodRSVM.cxx +++ /dev/null @@ -1,388 +0,0 @@ -// @(#)root/tmva/rmva $Id$ -// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015 - -/********************************************************************************** - * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * - * Package: TMVA * - * Class : MethodRSVM- * - * Web : http://oproject.org * - * * - * Description: * - * Support Vector Machines * - * * - * * - * Redistribution and use in source and binary forms, with or without * - * modification, are permitted according to the terms listed in LICENSE * - * (see tmva/doc/LICENSE) * - * * - **********************************************************************************/ - -#include - -#include "TMath.h" -#include "Riostream.h" -#include "TMatrix.h" -#include "TMatrixD.h" -#include "TVectorD.h" - -#include "TMVA/VariableTransformBase.h" -#include "TMVA/MethodRSVM.h" -#include "TMVA/Tools.h" -#include "TMVA/Config.h" -#include "TMVA/Ranking.h" -#include "TMVA/Types.h" -#include "TMVA/PDF.h" -#include "TMVA/ClassifierFactory.h" - -#include "TMVA/Results.h" -#include "TMVA/Timer.h" - -using namespace TMVA; - -REGISTER_METHOD(RSVM) - -//creating an Instance -Bool_t MethodRSVM::IsModuleLoaded = ROOT::R::TRInterface::Instance().Require("e1071"); - - -//_______________________________________________________________________ -MethodRSVM::MethodRSVM(const TString &jobName, - const TString &methodTitle, - DataSetInfo &dsi, - const TString &theOption) : - RMethodBase(jobName, Types::kRSVM, methodTitle, dsi, theOption), - fMvaCounter(0), - svm("svm"), - predict("predict"), - asfactor("as.factor"), - fModel(NULL) -{ - // standard constructor for the RSVM - //Booking options - fScale = kTRUE; - fType = "C-classification"; - fKernel = "radial"; - fDegree = 3; - - fGamma = (fDfTrain.GetNcols() == 1) ? 1.0 : (1.0 / fDfTrain.GetNcols()); - fCoef0 = 0; - fCost = 1; - fNu = 0.5; - fCacheSize = 40; - fTolerance = 0.001; - fEpsilon = 0.1; - fShrinking = kTRUE; - fCross = 0; - fProbability = kFALSE; - fFitted = kTRUE; -} - -//_______________________________________________________________________ -MethodRSVM::MethodRSVM(DataSetInfo &theData, const TString &theWeightFile) - : RMethodBase(Types::kRSVM, theData, theWeightFile), - fMvaCounter(0), - svm("svm"), - predict("predict"), - asfactor("as.factor"), - fModel(NULL) -{ - // standard constructor for the RSVM - //Booking options - fScale = kTRUE; - fType = "C-classification"; - fKernel = "radial"; - fDegree = 3; - - fGamma = (fDfTrain.GetNcols() == 1) ? 1.0 : (1.0 / fDfTrain.GetNcols()); - fCoef0 = 0; - fCost = 1; - fNu = 0.5; - fCacheSize = 40; - fTolerance = 0.001; - fEpsilon = 0.1; - fShrinking = kTRUE; - fCross = 0; - fProbability = kTRUE; - fFitted = kTRUE; -} - - -//_______________________________________________________________________ -MethodRSVM::~MethodRSVM(void) -{ - if (fModel) delete fModel; -} - -//_______________________________________________________________________ -Bool_t MethodRSVM::HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t /*numberTargets*/) -{ - if (type == Types::kClassification && numberClasses == 2) return kTRUE; - return kFALSE; -} - - -//_______________________________________________________________________ -void MethodRSVM::Init() -{ - if (!IsModuleLoaded) { - Error("Init", "R's package e1071 can not be loaded."); - Log() << kFATAL << " R's package e1071 can not be loaded." - << Endl; - return; - } -} - -void MethodRSVM::Train() -{ - if (Data()->GetNTrainingEvents() == 0) Log() << kFATAL << " Data() has zero events" << Endl; - //SVM require a named vector - ROOT::R::TRDataFrame ClassWeightsTrain; - ClassWeightsTrain["background"] = Data()->GetNEvtBkgdTrain(); - ClassWeightsTrain["signal"] = Data()->GetNEvtSigTrain(); - - Log() << kINFO - << " Probability is " << fProbability - << " Tolerance is " << fTolerance - << " Type is " << fType - << Endl; - - - SEXP Model = svm(ROOT::R::Label["x"] = fDfTrain, \ - ROOT::R::Label["y"] = asfactor(fFactorTrain), \ - ROOT::R::Label["scale"] = fScale, \ - ROOT::R::Label["type"] = fType, \ - ROOT::R::Label["kernel"] = fKernel, \ - ROOT::R::Label["degree"] = fDegree, \ - ROOT::R::Label["gamma"] = fGamma, \ - ROOT::R::Label["coef0"] = fCoef0, \ - ROOT::R::Label["cost"] = fCost, \ - ROOT::R::Label["nu"] = fNu, \ - ROOT::R::Label["class.weights"] = ClassWeightsTrain, \ - ROOT::R::Label["cachesize"] = fCacheSize, \ - ROOT::R::Label["tolerance"] = fTolerance, \ - ROOT::R::Label["epsilon"] = fEpsilon, \ - ROOT::R::Label["shrinking"] = fShrinking, \ - ROOT::R::Label["cross"] = fCross, \ - ROOT::R::Label["probability"] = fProbability, \ - ROOT::R::Label["fitted"] = fFitted); - fModel = new ROOT::R::TRObject(Model); - if (IsModelPersistence()) - { - TString path = GetWeightFileDir() + "/" + GetName() + ".RData"; - Log() << Endl; - Log() << gTools().Color("bold") << "--- Saving State File In:" << gTools().Color("reset") << path << Endl; - Log() << Endl; - r["RSVMModel"] << Model; - r << "save(RSVMModel,file='" + path + "')"; - } -} - -//_______________________________________________________________________ -void MethodRSVM::DeclareOptions() -{ - DeclareOptionRef(fScale, "Scale", "A logical vector indicating the variables to be scaled. If\ - ‘scale’ is of length 1, the value is recycled as many times \ - as needed. Per default, data are scaled internally (both ‘x’\ - and ‘y’ variables) to zero mean and unit variance. The center \ - and scale values are returned and used for later predictions."); - DeclareOptionRef(fType, "Type", "‘svm’ can be used as a classification machine, as a \ - regression machine, or for novelty detection. Depending of\ - whether ‘y’ is a factor or not, the default setting for\ - ‘type’ is ‘C-classification’ or ‘eps-regression’,\ - respectively, but may be overwritten by setting an explicit value.\ - Valid options are:\ - - ‘C-classification’\ - - ‘nu-classification’\ - - ‘one-classification’ (for novelty detection)\ - - ‘eps-regression’\ - - ‘nu-regression’"); - DeclareOptionRef(fKernel, "Kernel", "the kernel used in training and predicting. You might\ - consider changing some of the following parameters, depending on the kernel type.\ - linear: u'*v\ - polynomial: (gamma*u'*v + coef0)^degree\ - radial basis: exp(-gamma*|u-v|^2)\ - sigmoid: tanh(gamma*u'*v + coef0)"); - DeclareOptionRef(fDegree, "Degree", "parameter needed for kernel of type ‘polynomial’ (default: 3)"); - DeclareOptionRef(fGamma, "Gamma", "parameter needed for all kernels except ‘linear’ (default:1/(data dimension))"); - DeclareOptionRef(fCoef0, "Coef0", "parameter needed for kernels of type ‘polynomial’ and ‘sigmoid’ (default: 0)"); - DeclareOptionRef(fCost, "Cost", "cost of constraints violation (default: 1)-it is the ‘C’-constant of the regularization term in the Lagrange formulation."); - DeclareOptionRef(fNu, "Nu", "parameter needed for ‘nu-classification’, ‘nu-regression’,and ‘one-classification’"); - DeclareOptionRef(fCacheSize, "CacheSize", "cache memory in MB (default 40)"); - DeclareOptionRef(fTolerance, "Tolerance", "tolerance of termination criterion (default: 0.001)"); - DeclareOptionRef(fEpsilon, "Epsilon", "epsilon in the insensitive-loss function (default: 0.1)"); - DeclareOptionRef(fShrinking, "Shrinking", "option whether to use the shrinking-heuristics (default:‘TRUE’)"); - DeclareOptionRef(fCross, "Cross", "if a integer value k>0 is specified, a k-fold cross validation on the training data is performed to assess the quality of the model: the accuracy rate for classification and the Mean Squared Error for regression"); - DeclareOptionRef(fProbability, "Probability", "logical indicating whether the model should allow for probability predictions"); - DeclareOptionRef(fFitted, "Fitted", "logical indicating whether the fitted values should be computed and included in the model or not (default: ‘TRUE’)"); - -} - -//_______________________________________________________________________ -void MethodRSVM::ProcessOptions() -{ - r["RMVA.RSVM.Scale"] = fScale; - r["RMVA.RSVM.Type"] = fType; - r["RMVA.RSVM.Kernel"] = fKernel; - r["RMVA.RSVM.Degree"] = fDegree; - r["RMVA.RSVM.Gamma"] = fGamma; - r["RMVA.RSVM.Coef0"] = fCoef0; - r["RMVA.RSVM.Cost"] = fCost; - r["RMVA.RSVM.Nu"] = fNu; - r["RMVA.RSVM.CacheSize"] = fCacheSize; - r["RMVA.RSVM.Tolerance"] = fTolerance; - r["RMVA.RSVM.Epsilon"] = fEpsilon; - r["RMVA.RSVM.Shrinking"] = fShrinking; - r["RMVA.RSVM.Cross"] = fCross; - r["RMVA.RSVM.Probability"] = fProbability; - r["RMVA.RSVM.Fitted"] = fFitted; - -} - -//_______________________________________________________________________ -void MethodRSVM::TestClassification() -{ - Log() << kINFO << "Testing Classification RSVM METHOD " << Endl; - - MethodBase::TestClassification(); -} - - -//_______________________________________________________________________ -Double_t MethodRSVM::GetMvaValue(Double_t *errLower, Double_t *errUpper) -{ - NoErrorCalc(errLower, errUpper); - Double_t mvaValue; - const TMVA::Event *ev = GetEvent(); - const UInt_t nvar = DataInfo().GetNVariables(); - ROOT::R::TRDataFrame fDfEvent; - for (UInt_t i = 0; i < nvar; i++) { - fDfEvent[DataInfo().GetListOfVariables()[i].Data()] = ev->GetValues()[i]; - } - //if using persistence model - if (IsModelPersistence()) ReadStateFromFile(); - - ROOT::R::TRObject result = predict(*fModel, fDfEvent, ROOT::R::Label["decision.values"] = kTRUE, ROOT::R::Label["probability"] = kTRUE); - TVectorD values = result.GetAttribute("decision.values"); - mvaValue = values[0]; //returning signal prob - return mvaValue; -} - -//////////////////////////////////////////////////////////////////////////////// -/// get all the MVA values for the events of the current Data type -std::vector MethodRSVM::GetMvaValues(Long64_t firstEvt, Long64_t lastEvt, Bool_t logProgress) -{ - Long64_t nEvents = Data()->GetNEvents(); - if (firstEvt > lastEvt || lastEvt > nEvents) lastEvt = nEvents; - if (firstEvt < 0) firstEvt = 0; - - nEvents = lastEvt-firstEvt; - - UInt_t nvars = Data()->GetNVariables(); - - // use timer - Timer timer( nEvents, GetName(), kTRUE ); - if (logProgress) - Log() << kINFO<GetCurrentType()==Types::kTraining?"training":"testing") << " sample (" << nEvents << " events)" << Endl; - - - // fill R DATA FRAME with events data - std::vector > inputData(nvars); - for (UInt_t i = 0; i < nvars; i++) { - inputData[i] = std::vector(nEvents); - } - - for (Int_t ievt=firstEvt; ievtSetCurrentEvent(ievt); - const TMVA::Event *e = Data()->GetEvent(); - assert(nvars == e->GetNVariables()); - for (UInt_t i = 0; i < nvars; i++) { - inputData[i][ievt] = e->GetValue(i); - } - // if (ievt%100 == 0) - // std::cout << "Event " << ievt << " type" << DataInfo().IsSignal(e) << " : " << pValue[ievt*nvars] << " " << pValue[ievt*nvars+1] << " " << pValue[ievt*nvars+2] << std::endl; - } - - ROOT::R::TRDataFrame evtData; - for (UInt_t i = 0; i < nvars; i++) { - evtData[DataInfo().GetListOfVariables()[i].Data()] = inputData[i]; - } - //if using persistence model - if (IsModelPersistence()) ReadModelFromFile(); - - std::vector mvaValues(nEvents); - - - ROOT::R::TRObject result = predict(*fModel, evtData, ROOT::R::Label["decision.values"] = kTRUE, ROOT::R::Label["probability"] = kTRUE); - - r["result"] << result; - r << "v2 <- attr(result, \"probabilities\") "; - int probSize = 0; - r["length(v2)"] >> probSize; - //r << "print(v2)"; - if (probSize > 0) { - std::vector probValues = result.GetAttribute("probabilities"); - // probabilities are for both cases - assert(probValues.size() == 2*mvaValues.size()); - for (int i = 0; i < nEvents; ++i) - // R stores vector column-wise (as in Fortran) - // and signal probabilities are the second column - mvaValues[i] = probValues[nEvents+i]; - - } - // use decision values - else { - Log() << kINFO << " : Probabilities are not available. Use decision values instead !" << Endl; - //std::cout << "examine the result " << std::endl; - std::vector probValues = result.GetAttribute("decision.values"); - mvaValues = probValues; - // std::cout << "decision values " << values1.size() << std::endl; - // for ( auto & v : values1) std::cout << v << " "; - // std::cout << std::endl; - } - - - if (logProgress) { - Log() << kINFO <> Model; - fModel = new ROOT::R::TRObject(Model); - -} - -//_______________________________________________________________________ -void MethodRSVM::GetHelpMessage() const -{ -// get help message text -// -// typical length of text line: -// "|--------------------------------------------------------------|" - Log() << Endl; - Log() << gTools().Color("bold") << "--- Short description:" << gTools().Color("reset") << Endl; - Log() << Endl; - Log() << "Decision Trees and Rule-Based Models " << Endl; - Log() << Endl; - Log() << gTools().Color("bold") << "--- Performance optimisation:" << gTools().Color("reset") << Endl; - Log() << Endl; - Log() << Endl; - Log() << gTools().Color("bold") << "--- Performance tuning via configuration options:" << gTools().Color("reset") << Endl; - Log() << Endl; - Log() << "" << Endl; -} - diff --git a/tmva/rmva/src/MethodRXGB.cxx b/tmva/rmva/src/MethodRXGB.cxx deleted file mode 100644 index ed0e01be2dd70..0000000000000 --- a/tmva/rmva/src/MethodRXGB.cxx +++ /dev/null @@ -1,282 +0,0 @@ -// @(#)root/tmva/rmva $Id$ -// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015 - -/********************************************************************************** - * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * - * Package: TMVA * - * Class : MethodRXGB * - * Web : http://oproject.org * - * * - * Description: * - * R eXtreme Gradient Boosting * - * * - * * - * Redistribution and use in source and binary forms, with or without * - * modification, are permitted according to the terms listed in LICENSE * - * (see tmva/doc/LICENSE) * - * * - **********************************************************************************/ - -#include - -#include "TMath.h" -#include "Riostream.h" -#include "TMatrix.h" -#include "TMatrixD.h" -#include "TVectorD.h" - -#include "TMVA/VariableTransformBase.h" -#include "TMVA/MethodRXGB.h" -#include "TMVA/Tools.h" -#include "TMVA/Config.h" -#include "TMVA/Ranking.h" -#include "TMVA/Types.h" -#include "TMVA/PDF.h" -#include "TMVA/ClassifierFactory.h" - -#include "TMVA/Results.h" -#include "TMVA/Timer.h" - -using namespace TMVA; - -REGISTER_METHOD(RXGB) - - -//creating an Instance -Bool_t MethodRXGB::IsModuleLoaded = ROOT::R::TRInterface::Instance().Require("xgboost"); - -//_______________________________________________________________________ -MethodRXGB::MethodRXGB(const TString &jobName, - const TString &methodTitle, - DataSetInfo &dsi, - const TString &theOption) : RMethodBase(jobName, Types::kRXGB, methodTitle, dsi, theOption), - fNRounds(10), - fEta(0.3), - fMaxDepth(6), - predict("predict", "xgboost"), - xgbtrain("xgboost"), - xgbdmatrix("xgb.DMatrix"), - xgbsave("xgb.save"), - xgbload("xgb.load"), - asfactor("as.factor"), - asmatrix("as.matrix"), - fModel(NULL) -{ - // standard constructor for the RXGB - -} - -//_______________________________________________________________________ -MethodRXGB::MethodRXGB(DataSetInfo &theData, const TString &theWeightFile) - : RMethodBase(Types::kRXGB, theData, theWeightFile), - fNRounds(10), - fEta(0.3), - fMaxDepth(6), - predict("predict", "xgboost"), - xgbtrain("xgboost"), - xgbdmatrix("xgb.DMatrix"), - xgbsave("xgb.save"), - xgbload("xgb.load"), - asfactor("as.factor"), - asmatrix("as.matrix"), - fModel(NULL) -{ - -} - - -//_______________________________________________________________________ -MethodRXGB::~MethodRXGB(void) -{ - if (fModel) delete fModel; -} - -//_______________________________________________________________________ -Bool_t MethodRXGB::HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t /*numberTargets*/) -{ - if (type == Types::kClassification && numberClasses == 2) return kTRUE; - return kFALSE; -} - - -//_______________________________________________________________________ -void MethodRXGB::Init() -{ - - if (!IsModuleLoaded) { - Error("Init", "R's package xgboost can not be loaded."); - Log() << kFATAL << " R's package xgboost can not be loaded." - << Endl; - return; - } - //factors creations - //xgboost require a numeric factor then background=0 signal=1 from fFactorTrain - UInt_t size = fFactorTrain.size(); - fFactorNumeric.resize(size); - - for (UInt_t i = 0; i < size; i++) { - if (fFactorTrain[i] == "signal") fFactorNumeric[i] = 1; - else fFactorNumeric[i] = 0; - } - - - -} - -void MethodRXGB::Train() -{ - if (Data()->GetNTrainingEvents() == 0) Log() << kFATAL << " Data() has zero events" << Endl; - ROOT::R::TRObject dmatrix = xgbdmatrix(ROOT::R::Label["data"] = asmatrix(fDfTrain), ROOT::R::Label["label"] = fFactorNumeric); - ROOT::R::TRDataFrame params; - params["eta"] = fEta; - params["max.depth"] = fMaxDepth; - - SEXP Model = xgbtrain(ROOT::R::Label["data"] = dmatrix, - ROOT::R::Label["label"] = fFactorNumeric, - ROOT::R::Label["weight"] = fWeightTrain, - ROOT::R::Label["nrounds"] = fNRounds, - ROOT::R::Label["params"] = params); - - fModel = new ROOT::R::TRObject(Model); - if (IsModelPersistence()) - { - TString path = GetWeightFileDir() + "/" + GetName() + ".RData"; - Log() << Endl; - Log() << gTools().Color("bold") << "--- Saving State File In:" << gTools().Color("reset") << path << Endl; - Log() << Endl; - xgbsave(Model, path); - } -} - -//_______________________________________________________________________ -void MethodRXGB::DeclareOptions() -{ - DeclareOptionRef(fNRounds, "NRounds", "The max number of iterations"); - DeclareOptionRef(fEta, "Eta", "Step size shrinkage used in update to prevents overfitting. After each boosting step, we can directly get the weights of new features. and eta actually shrinks the feature weights to make the boosting process more conservative."); - DeclareOptionRef(fMaxDepth, "MaxDepth", "Maximum depth of the tree"); -} - -//_______________________________________________________________________ -void MethodRXGB::ProcessOptions() -{ -} - -//_______________________________________________________________________ -void MethodRXGB::TestClassification() -{ - Log() << kINFO << "Testing Classification RXGB METHOD " << Endl; - MethodBase::TestClassification(); -} - - -//_______________________________________________________________________ -Double_t MethodRXGB::GetMvaValue(Double_t *errLower, Double_t *errUpper) -{ - NoErrorCalc(errLower, errUpper); - Double_t mvaValue; - const TMVA::Event *ev = GetEvent(); - const UInt_t nvar = DataInfo().GetNVariables(); - ROOT::R::TRDataFrame fDfEvent; - for (UInt_t i = 0; i < nvar; i++) { - fDfEvent[DataInfo().GetListOfVariables()[i].Data()] = ev->GetValues()[i]; - } - //if using persistence model - if (IsModelPersistence()) ReadStateFromFile(); - - mvaValue = (Double_t)predict(*fModel, xgbdmatrix(ROOT::R::Label["data"] = asmatrix(fDfEvent))); - return mvaValue; -} - -//////////////////////////////////////////////////////////////////////////////// -/// get all the MVA values for the events of the current Data type -std::vector MethodRXGB::GetMvaValues(Long64_t firstEvt, Long64_t lastEvt, Bool_t logProgress) -{ - Long64_t nEvents = Data()->GetNEvents(); - if (firstEvt > lastEvt || lastEvt > nEvents) lastEvt = nEvents; - if (firstEvt < 0) firstEvt = 0; - - nEvents = lastEvt-firstEvt; - - UInt_t nvars = Data()->GetNVariables(); - - // use timer - Timer timer( nEvents, GetName(), kTRUE ); - if (logProgress) - Log() << kINFO<GetCurrentType()==Types::kTraining?"training":"testing") << " sample (" << nEvents << " events)" << Endl; - - - // fill R DATA FRAME with events data - std::vector > inputData(nvars); - for (UInt_t i = 0; i < nvars; i++) { - inputData[i] = std::vector(nEvents); - } - - for (Int_t ievt=firstEvt; ievtSetCurrentEvent(ievt); - const TMVA::Event *e = Data()->GetEvent(); - assert(nvars == e->GetNVariables()); - for (UInt_t i = 0; i < nvars; i++) { - inputData[i][ievt] = e->GetValue(i); - } - // if (ievt%100 == 0) - // std::cout << "Event " << ievt << " type" << DataInfo().IsSignal(e) << " : " << pValue[ievt*nvars] << " " << pValue[ievt*nvars+1] << " " << pValue[ievt*nvars+2] << std::endl; - } - - ROOT::R::TRDataFrame evtData; - for (UInt_t i = 0; i < nvars; i++) { - evtData[DataInfo().GetListOfVariables()[i].Data()] = inputData[i]; - } - //if using persistence model - if (IsModelPersistence()) ReadModelFromFile(); - - std::vector mvaValues(nEvents); - ROOT::R::TRObject pred = predict(*fModel, xgbdmatrix(ROOT::R::Label["data"] = asmatrix(evtData))); - mvaValues = pred.As>(); - - if (logProgress) { - Log() << kINFO <" << Endl; -} - -//_______________________________________________________________________ -void TMVA::MethodRXGB::ReadModelFromFile() -{ - ROOT::R::TRInterface::Instance().Require("RXGB"); - TString path = GetWeightFileDir() + "/" + GetName() + ".RData"; - Log() << Endl; - Log() << gTools().Color("bold") << "--- Loading State File From:" << gTools().Color("reset") << path << Endl; - Log() << Endl; - - SEXP Model = xgbload(path); - fModel = new ROOT::R::TRObject(Model); - -} - -//_______________________________________________________________________ -void TMVA::MethodRXGB::MakeClass(const TString &/*theClassFileName*/) const -{ -} diff --git a/tmva/rmva/src/RMethodBase.cxx b/tmva/rmva/src/RMethodBase.cxx deleted file mode 100644 index 422152dfedca7..0000000000000 --- a/tmva/rmva/src/RMethodBase.cxx +++ /dev/null @@ -1,111 +0,0 @@ -// @(#)root/tmva/rmva $Id$ -// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015 - - -/********************************************************************************** - * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * - * Package: TMVA * - * Class : RMethodBase * - * * - * Description: * - * Virtual base class for all MVA method based on ROOTR * - * * - **********************************************************************************/ - -#include -#include -#include -using namespace TMVA; - - -//_______________________________________________________________________ -RMethodBase::RMethodBase(const TString &jobName, - Types::EMVA methodType, - const TString &methodTitle, - DataSetInfo &dsi, - const TString &theOption , ROOT::R::TRInterface &_r): MethodBase(jobName, methodType, methodTitle, dsi, theOption), - r(_r) -{ - LoadData(); -} - -//_______________________________________________________________________ -RMethodBase::RMethodBase(Types::EMVA methodType, - DataSetInfo &dsi, - const TString &weightFile,ROOT::R::TRInterface &_r): MethodBase(methodType, dsi, weightFile), - r(_r) -{ - LoadData(); -} - -//_______________________________________________________________________ -void RMethodBase::LoadData() -{ - /////////////////////////// - //Loading Training Data // - /////////////////////////// - const UInt_t nvar = DataInfo().GetNVariables(); - - const UInt_t ntrains = Data()->GetNTrainingEvents(); - - //array of columns for every var to create a dataframe for training - std::vector > fArrayTrain(nvar); -// Data()->SetCurrentEvent(1); -// Data()->SetCurrentType(Types::ETreeType::kTraining); - - fWeightTrain.ResizeTo(ntrains); - for (UInt_t j = 0; j < ntrains; j++) { - const Event *ev = Data()->GetEvent(j, Types::ETreeType::kTraining); -// const Event *ev=Data()->GetEvent( j ); - //creating array with class type(signal or background) for factor required - if (ev->GetClass() == Types::kSignal) fFactorTrain.push_back("signal"); - else fFactorTrain.push_back("background"); - - fWeightTrain[j] = ev->GetWeight(); - - //filling vector of columns for training - for (UInt_t i = 0; i < nvar; i++) { - fArrayTrain[i].push_back(ev->GetValue(i)); - } - - } - for (UInt_t i = 0; i < nvar; i++) { - fDfTrain[DataInfo().GetListOfVariables()[i].Data()] = fArrayTrain[i]; - } - //////////////////////// - //Loading Test Data // - //////////////////////// - - const UInt_t ntests = Data()->GetNTestEvents(); - const UInt_t nspectators = DataInfo().GetNSpectators(kTRUE); - - //array of columns for every var to create a dataframe for testing - std::vector > fArrayTest(nvar); - //array of columns for every spectator to create a dataframe for testing - std::vector > fArraySpectators(nvar); - fWeightTest.ResizeTo(ntests); -// Data()->SetCurrentType(Types::ETreeType::kTesting); - for (UInt_t j = 0; j < ntests; j++) { - const Event *ev = Data()->GetEvent(j, Types::ETreeType::kTesting); -// const Event *ev=Data()->GetEvent(j); - //creating array with class type(signal or background) for factor required - if (ev->GetClass() == Types::kSignal) fFactorTest.push_back("signal"); - else fFactorTest.push_back("background"); - - fWeightTest[j] = ev->GetWeight(); - - for (UInt_t i = 0; i < nvar; i++) { - fArrayTest[i].push_back(ev->GetValue(i)); - } - for (UInt_t i = 0; i < nspectators; i++) { - fArraySpectators[i].push_back(ev->GetSpectator(i)); - } - } - for (UInt_t i = 0; i < nvar; i++) { - fDfTest[DataInfo().GetListOfVariables()[i].Data()] = fArrayTest[i]; - } - for (UInt_t i = 0; i < nspectators; i++) { - fDfSpectators[DataInfo().GetSpectatorInfo(i).GetLabel().Data()] = fArraySpectators[i]; - } - -} diff --git a/tmva/rmva/test/Classification.C b/tmva/rmva/test/Classification.C deleted file mode 100644 index 89ec2d87b7bf7..0000000000000 --- a/tmva/rmva/test/Classification.C +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include - -#include "TChain.h" -#include "TFile.h" -#include "TTree.h" -#include "TString.h" -#include "TObjString.h" -#include "TSystem.h" -#include "TROOT.h" - - -#include "TMVA/Factory.h" -#include "TMVA/Tools.h" -#include -#include - - -void Classification() -{ - TMVA::Tools::Instance(); - ROOT::R::TRInterface &r = ROOT::R::TRInterface::Instance(); - - TString outfileName("RMVA.root"); - TFile *outputFile = TFile::Open(outfileName, "RECREATE"); - - TMVA::Factory *factory = new TMVA::Factory("RMVAClassification", outputFile, - "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=Classification"); - - TMVA::DataLoader *dataloader = new TMVA::DataLoader("dataset"); - - dataloader->AddVariable("myvar1 := var1+var2", 'F'); - dataloader->AddVariable("myvar2 := var1-var2", "Expression 2", "", 'F'); - dataloader->AddVariable("var3", "Variable 3", "units", 'F'); - dataloader->AddVariable("var4", "Variable 4", "units", 'F'); - dataloader->AddSpectator("spec1 := var1*2", "Spectator 1", "units", 'F'); - dataloader->AddSpectator("spec2 := var1*3", "Spectator 2", "units", 'F'); - - TFile *input(0); - TString fname = gROOT->GetTutorialDir() + "/machine_learning/data/tmva_class_example.root"; - if (!gSystem->AccessPathName( fname )) { - input = TFile::Open( fname ); // check if file in local directory exists - } - if (!input) { - std::cout << "ERROR: could not open data file " << fname << std::endl; - exit(1); - } - - std::cout << "--- TMVAClassification : Using input file: " << input->GetName() << std::endl; - - // --- Register the training and test trees - - TTree *tsignal = (TTree *)input->Get("TreeS"); - TTree *tbackground = (TTree *)input->Get("TreeB"); - - // global event weights per tree (see below for setting event-wise weights) - Double_t signalWeight = 1.0; - Double_t backgroundWeight = 1.0; - - // You can add an arbitrary number of signal or background trees - dataloader->AddSignalTree(tsignal, signalWeight); - dataloader->AddBackgroundTree(tbackground, backgroundWeight); - - - // Set individual event weights (the variables must exist in the original TTree) - dataloader->SetBackgroundWeightExpression("weight"); - - - // Apply additional cuts on the signal and background samples (can be different) - TCut mycuts = ""; // for example: TCut mycuts = "abs(var1)<0.5 && abs(var2-0.5)<1"; - TCut mycutb = ""; // for example: TCut mycutb = "abs(var1)<0.5"; - - // Tell the factory how to use the training and testing events - dataloader->PrepareTrainingAndTestTree(mycuts, mycutb, - "nTrain_Signal=0:nTrain_Background=0:nTest_Signal=0:nTest_Background=0:SplitMode=Random:NormMode=NumEvents:!V"); - - //R TMVA Methods - factory->BookMethod(dataloader, TMVA::Types::kC50, "C50", - "!H:NTrials=10:Rules=kFALSE:ControlSubSet=kFALSE:ControlBands=0:ControlWinnow=kFALSE:ControlNoGlobalPruning=kTRUE:ControlCF=0.25:ControlMinCases=2:ControlFuzzyThreshold=kTRUE:ControlSample=0:ControlEarlyStopping=kTRUE:!V"); - - factory->BookMethod(dataloader, TMVA::Types::kRXGB, "RXGB", "!V:NRounds=80:MaxDepth=2:Eta=1"); - - factory->BookMethod(dataloader, TMVA::Types::kRSNNS, "RMLP", "!H:VarTransform=N:Size=c(5):Maxit=200:InitFunc=Randomize_Weights:LearnFunc=Std_Backpropagation:LearnFuncParams=c(0.2,0):!V"); - - factory->BookMethod(dataloader, TMVA::Types::kRSVM, "RSVM", "!H:Kernel=linear:Type=C-classification:VarTransform=Norm:Probability=kTRUE:Tolerance=0.1:!V"); - - - // Train MVAs using the set of training events - factory->TrainAllMethods(); - - // ---- Evaluate all MVAs using the set of test events - factory->TestAllMethods(); - - // ----- Evaluate and compare performance of all configured MVAs - factory->EvaluateAllMethods(); - // -------------------------------------------------------------- - - // Save the output - outputFile->Close(); - - std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl; - std::cout << "==> TMVAClassification is done!" << std::endl; - - // delete factory; - r.SetVerbose(1); - -} diff --git a/tutorials/CMakeLists.txt b/tutorials/CMakeLists.txt index c10044e0d41b7..93f2ab646eb8d 100644 --- a/tutorials/CMakeLists.txt +++ b/tutorials/CMakeLists.txt @@ -229,10 +229,6 @@ if(NOT xrootd) ) endif() -if(NOT r) - set(r_veto math/r/*.C) -endif() - set(histfactory_veto roofit/histfactory/makeExample.C) if(NOT fitsio) @@ -518,7 +514,6 @@ set(all_veto hsimple.C ${fftw3_veto} ${opengl_veto} ${gviz_veto} - ${r_veto} ${runtime_cxxmodules_veto} ${histfactory_veto} ${tbb_veto} diff --git a/tutorials/math/r/DataFrame.C b/tutorials/math/r/DataFrame.C deleted file mode 100644 index dfd21e4eb9891..0000000000000 --- a/tutorials/math/r/DataFrame.C +++ /dev/null @@ -1,74 +0,0 @@ -/// \file -/// \ingroup tutorial_r -/// \notebook -nodraw -/// -/// \macro_code -/// -/// \author - -void DataFrame() -{ - using namespace ROOT::R; - // Creating variables - TVectorD v1(3); - std::vector v2 {0.101, 0.202, 0.303}; - std::array v3{ {1,2,3} }; - std::list names {"v1", "v2", "v3"}; - - // Assigning values - v1[0]=1; - v1[1]=2; - v1[2]=3; - - auto &r = TRInterface::Instance(); - - // Creating dataframe object with its labels - - TRDataFrame df1(Label["var1"]=v1,Label["var2"]=v2,Label["var3"]=v3,Label["strings"]=names); - - // Passing dataframe to R's environment - - r["df1"]<>v4; - //adding new colunm to df1 with name var4 - df1["var4"]=v4; - //updating df1 in R's environment - r["df1"]<>df2; - - TVectorD v(3); - df2["v1"]>>v; - v.Print(); - - df2["v2"]>>v; - v.Print(); - - // Working with colunms between dataframes - - df2["v3"]<>df1["var1"]; - - // Updating df1 in R's environment - r["df1"]<IsBatch()) { - devnew("Fitting Regression"); - plot(xdata,ydata); - - TRObject xgrid=seq(rmin(xdata),rmax(xdata),Label["len"]=10); - lines(xgrid,predict(fit,xgrid),Label["col"] = "green"); - devoff(Label["which"] = devcur() ); - } -} diff --git a/tutorials/math/r/Functor.C b/tutorials/math/r/Functor.C deleted file mode 100644 index 2ef3c4634507f..0000000000000 --- a/tutorials/math/r/Functor.C +++ /dev/null @@ -1,86 +0,0 @@ -/// \file -/// \ingroup tutorial_r -/// \notebook -nodraw -/// Example to create class Functor -/// -/// \macro_code -/// -/// \author Omar Zapata - -#include -#include - -typedef Double_t (*Function)(Double_t); - -//Functor class with the function inside -class MyFunctor{ -public: - MyFunctor() { - status=false; - f=TMath::BesselY1; - } - - void setFunction(Function fun) { - f=fun; - status=true; - } - - Bool_t getStatus(){return status;} - - Double_t doEval(Double_t x) { - return f(x); - } - -private: - Function f; - Bool_t status; -}; - -// this macro exposes the class into R's enviornment -// and lets you pass objects directly. -ROOTR_EXPOSED_CLASS(MyFunctor) - -// Macro to create a module -ROOTR_MODULE(MyFunctorModule) { - ROOT::R::class_( "MyFunctor" ) - //creating a default constructor - .constructor() - //adding the method doEval to evaluate the internal function - .method( "doEval", &MyFunctor::doEval ) - .method( "getStatus", &MyFunctor::getStatus) - ; -} - -void Functor() -{ - ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); - - // Creating functor with default function TMath::BesselY1 - // and status false from R's environment - // Loading module into R's enviornment - r["MyFunctorModule"]<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/math/r/Integration.C b/tutorials/math/r/Integration.C deleted file mode 100644 index 84d7925023972..0000000000000 --- a/tutorials/math/r/Integration.C +++ /dev/null @@ -1,59 +0,0 @@ -/// \file -/// \ingroup tutorial_r -/// \notebook -nodraw -/// Numerical integration using R passing the function from ROOT -/// -/// \macro_code -/// -/// \author - -#include -#include -#include -#include - -//To integrate using R the function must be vectorized -//The idea is just to receive a vector like an argument,to evaluate -//every element saving the result in another vector -//and return the resultant vector. -std::vector BreitWignerVectorized(std::vector xx) -{ - std::vector result(xx.size()); - for(Int_t i=0;iIsBatch() ) { - - 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))"; - - //plotting the points - r<<"plot(x, y, main = 'approx(.) and approxfun(.)')"; - - //The function "approx" returns a list with components x and y - //containing n coordinates which interpolate the given data points according to the method (and rule) desired. - r<<"points(approx(x, y), col = 2, pch = '*')"; - r<<"points(approx(x, y, method = 'constant'), col = 4, pch = '*')"; - } - else { - r << "print('Interpolated points')"; - r << "print(approx(x,y,n=20))"; - } - - //The function "approxfun" returns a function performing (linear or constant) - //interpolation of the given data. - //For a given set of x values, this function will return the corresponding interpolated values. - r<<"f <- approxfun(x, y)"; - //using approxfun with const method - r<<"fc <- approxfun(x, y, method = 'const')"; - - if (!gROOT->IsBatch() ) { - r<<"curve(f(x), 0, 11, col = 'green2')"; - r<<"points(x, y)"; - - 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)"; - } - else { - r << "x2=x+0.5"; - r << "print('Result of approxfun with default method')"; - r << "print(paste('x = ',x,' f(x) = ',f(x2)))"; - r << "print('Result of approxfun with const method')"; - r << "print(paste('x = ',x,' f(x) = ',fc(x2)))"; - } -} diff --git a/tutorials/math/r/Minimization.C b/tutorials/math/r/Minimization.C deleted file mode 100644 index 85968ae858257..0000000000000 --- a/tutorials/math/r/Minimization.C +++ /dev/null @@ -1,71 +0,0 @@ -/// \file -/// \ingroup tutorial_r -/// \notebook -nodraw -/// Example based on -/// http://stat.ethz.ch/R-manual/R-devel/library/stats/html/optim.html -/// -/// \macro_code -/// -/// \author Omar Zapata - -#include - -//in the next function the *double pointer must be changed by a TVectorD, -//because the pointer has no meaning in R enviroment. -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(); - - //passsing RosenBrock function to R - r["RosenBrock"]=ROOT::R::TRFunctionExport(RosenBrock); - - //passsing RosenBrockGrad function to R - 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 - //"maxit" The maximum number of iterations. - //"abstol" The absolute convergence tolerance. - r.Execute("result <- optim( c(0.01,0.01), RosenBrock,method='BFGS',control = list(maxit = 1000000) )"); - //"reltol" Relative convergence tolerance. - - //Getting results from R - TVectorD min=r.Eval("result$par"); - - std::cout.precision(8); - //printing results - std::cout<<"-----------------------------------------"<SetGrid(); - - // draw a frame to define the range - TMultiGraph *mg = new TMultiGraph(); - - // create the first plot (points with gaussian noise) - const Int_t n = 24; - Double_t x1[n] ; - Double_t y1[n] ; - //Generate the points along a X^3 with noise - TRandom rg; - rg.SetSeed(520); - for (Int_t i = 0; i < n; i++) { - x1[i] = rg.Uniform(0, 1); - y1[i] = TMath::Power(x1[i], 3) + rg.Gaus() * 0.06; - } - - TGraph *gr1 = new TGraph(n,x1,y1); - gr1->SetMarkerColor(kBlue); - gr1->SetMarkerStyle(8); - gr1->SetMarkerSize(1); - mg->Add(gr1); - - // create the second plot - 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 data to Rfot 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; -} diff --git a/tutorials/math/r/example.C b/tutorials/math/r/example.C deleted file mode 100644 index 8d7dc23d2f594..0000000000000 --- a/tutorials/math/r/example.C +++ /dev/null @@ -1,67 +0,0 @@ -/// \file -/// \ingroup tutorial_r -/// \notebook -nodraw -/// Simple example on how to use ROOT-R interface. -/// -/// \macro_code -/// -/// \author - -#include "TMath.h" -#include "Math/PdfFunc.h" -#include "TMatrixD.h" -#include "TError.h" -#include -#include -#include "TRInterface.h" - -void example() { - ROOT::R::TRInterface &r = ROOT::R::TRInterface::Instance(); - // print R version - r.Execute("print(version$version.string)"); - - // compute standard deviation of 1000 vector normal numbers - - double std_dev_r = r.Eval("sd(rnorm(10000))"); - std::vector v = r.Eval("rnorm(10000)"); - double std_dev_root = TMath::StdDev(v.begin(),v.end()); - std::cout << "standard deviation from R = " << std_dev_r << std::endl; - std::cout << "standard deviation from ROOT = " << std_dev_root << std::endl; - if (!TMath::AreEqualAbs(std_dev_r,std_dev_root,0.1)) - Error("ROOT-R-Example","Different std-dev found"); - - // use << to execute the R command instead of Execute - r << "mat<-matrix(c(1,2,3,4,5,6),2,3,byrow=TRUE)"; - TMatrixD m = r["mat"]; - std::array a = r.Eval("seq(1:6)"); - TMatrixD m2(2,3,a.data()); - - if (!(m==m2)) { - Error("ROOT-R-Example","Different matrix found"); - m.Print(); - m2.Print(); - } - - // example on how to pass ROOT objects to R - std::vector v_root{1,2,3,4,5,6,7,8}; - r["v"] = v_root; - r << "v2<-seq(1:8)"; - bool isEqual = r.Eval("prod(v==v2)"); - if (!isEqual) { - Error("ROOT-R-Example","Different vector created"); - r << "print(v)"; - r << "print(v2)"; - } - - // example on how to pass functions to R - - r["gaus_pdf"] = ROOT::Math::normal_pdf; - - r << "y<-gaus_pdf(0,1,1)"; - double value_r = r["y"]; - double value_root = ROOT::Math::normal_pdf(0,1,1); - std::cout << "Function gaussian(0,1,1) evaluated in R = " << value_r << std::endl; - std::cout << "Function gaussian(0,1,1) evaluated in ROOT = " << value_root << std::endl; - if (value_r != value_root) - Error("ROOT-R-Example","Different function value found in r = %f and ROOT = %f", value_r, value_root); -}