Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Functions.C
Go to the documentation of this file.
1//script to test TRFunction
2#include<TRInterface.h>
3#include<TMath.h>
4double funv(TVectorD v)
5{
6 return v[0] * v[1];
7}
8
10{
11 m.Print();
12}
13
15{
16 std::cout << "hello " << s.Data() << std::endl;
17}
18
19//this prototype dont work because argument should be
20//an object to pass an array.
22{
23 return x[0] * par[0];
24}
25
27{
28 return x * 3;;
29}
30
31
32void Functions(TString type = "Import")
33{
35 r.SetVerbose(kFALSE);
36 if (type == "Export") {
37 std::cout << "-----------------------" << std::endl;
38 std::cout << "Testing FunctionExport" << std::endl;
39 std::cout << "-----------------------" << std::endl;
41 r << "print(funv(c(2,3)))";
42
44 r << "cat(funm(matrix(c(1,2,3,4),2,2)))";
45
47
48 r << "cat(funs('ROOTR'))";
49
51 r << "print(DiLog(2))";
52
53 r << "x <- seq(0,10,0.01)";
54 r << "y <- NULL ";
55 r << "for(i in seq(along=x)) { \
56 y <- c(y,DiLog(i)) \
57 }";
58
60 f4.SetFunction(fun4);
61 r["fun4"] << f4;
62 r << "print(fun4(1))";
63 } else {
64 std::cout << "-----------------------" << std::endl;
65 std::cout << "Testing FunctionImport " << std::endl;
66 std::cout << "-----------------------" << std::endl;
67 ROOT::R::TRFunctionImport print("print");
68 print("Hola");
69
71 ROOT::R::TRFunctionImport require("require");
73 ROOT::R::TRFunctionImport devoff("dev.off");
74//
76// ROOT::R::TRFunctionImport options("options");
78 ROOT::R::TRFunctionImport read("read.csv");
79 ROOT::R::TRFunctionImport head("head");
80 ROOT::R::TRFunctionImport aslist("as.list");
81
82 ROOT::R::TRFunctionImport options("options");
83 options(ROOT::R::Label["device"]="x11");
84
85
86 r<<"test <- function() x11";
88
89
91
92// dev();
93
94
95 options("device='x11'");
96//
97 ROOT::R::TRObject vector=c(1,2,3,4);
98 TVectorF v=vector;
99 TVectorF v2=c(11,22,33,44);
100 print(v);
101 print(v2);
102 ROOT::R::TRDataFrame obj=read("training.csv");
103
104// ROOT::R::TRDataFrame df(obj.As<ROOT::R::TRDataFrame>());
105 print(head(Rcpp::wrap(obj)));
106 print(head(obj));
107 x11();
108 plot(sin,0,6,ROOT::R::Label["type"]="s");
109 x11();
110 plot(sin,0,6,ROOT::R::Label["type"]="l");
111 x11();
112 plot(sin,0,6,ROOT::R::Label["type"]="p");
113
114
115
116// devoff();
117// print(vector);
118
119// require("C50");
120 }
121}
void funm(TMatrixD m)
Definition Functions.C:9
Double_t fun3(Double_t *x, Double_t *par)
Definition Functions.C:21
void funs(TString s)
Definition Functions.C:14
Double_t fun4(Double_t x)
Definition Functions.C:26
double funv(TVectorD v)
Definition Functions.C:4
void Functions(TString type="Import")
Definition Functions.C:32
#define c(i)
Definition RSha256.hxx:101
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
winID h TVirtualViewer3D TVirtualGLPainter char TVirtualGLPainter plot
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
This is a class to create DataFrames from ROOT to R.
This is a class to pass functions from ROOT to R.
void SetFunction(T fun)
function to assign function to export, template method that supports a lot of function's prototypes
This is a class to pass functions from ROOT to R.
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
static TRInterface & Instance()
static method to get an TRInterface instance reference
This is a class to get ROOT's objects from R's objects.
Definition TRObject.h:70
void Print(Option_t *option="") const override
Dump this marker with its attributes.
Definition TMarker.cxx:335
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:380
Double_t x[n]
Definition legend1.C:17
const Rcpp::internal::NamedPlaceHolder & Label
SEXP wrap(const TString &s)
Definition RExports.h:82
Double_t DiLog(Double_t x)
Modified Struve functions of order 1.
Definition TMath.cxx:116
Definition test.py:1
TMarker m
Definition textangle.C:8