Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RExports.cxx
Go to the documentation of this file.
1// Author: Omar Zapata Omar.Zapata@cern.ch 2014
2
3/*************************************************************************
4 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10#include<RExports.h>
11#include<TRFunctionExport.h>
12#include<TRObject.h>
13#include<TRDataFrame.h>
14
15namespace ROOT {
16 namespace R {
17 const Rcpp::internal::NamedPlaceHolder &Label(Rcpp::_);
18 }
19}
20
21namespace Rcpp {
22//TVectorT
23 template<> SEXP wrap(const TVectorT<Double_t> &v)
24 {
25 std::vector<Double_t> vec(v.GetMatrixArray(), v.GetMatrixArray() + v.GetNoElements());
26 return wrap(vec);
27 }
28
29 template<> TVectorT<Double_t> as(SEXP v)
30 {
31 std::vector<Double_t> vec =::Rcpp::as<std::vector<Double_t> >(v);
32 return TVectorT<Double_t>(vec.size(), vec.data());
33 }
34
35 template<> SEXP wrap(const TVectorT<Float_t> &v)
36 {
37 std::vector<Float_t> vec(v.GetMatrixArray(), v.GetMatrixArray() + v.GetNoElements());
38 return wrap(vec);
39 }
40
41 template<> TVectorT<Float_t> as(SEXP v)
42 {
43 std::vector<Float_t> vec =::Rcpp::as<std::vector<Float_t> >(v);
44 return TVectorT<Float_t>(vec.size(), vec.data());
45 }
46
47//TMatrixT
48 template<> SEXP wrap(const TMatrixT<Double_t> &m)
49 {
50 Int_t rows = m.GetNrows();
51 Int_t cols = m.GetNcols();
52 Double_t *data = new Double_t[rows * cols];
53 m.GetMatrix2Array(data, "F"); //ROOT has a bug here(Fixed)
54 NumericMatrix mat(rows, cols, data);
55 return wrap(mat);
56 }
57
58 template<> TMatrixT<Double_t> as(SEXP m)
59 {
60 NumericMatrix mat =::Rcpp::as<NumericMatrix>(m);
61 return TMatrixT<Double_t>(mat.rows(), mat.cols(), mat.begin(), "F");
62 }
63
64 template<> SEXP wrap(const TMatrixT<Float_t> &m)
65 {
66 Int_t rows = m.GetNrows();
67 Int_t cols = m.GetNcols();
68 Float_t *data = new Float_t[rows * cols];
69 m.GetMatrix2Array(data, "F"); //ROOT has a bug here(Fixed)
70 NumericMatrix mat(rows, cols, data);
71 return wrap(mat);
72 }
73
74 template<> TMatrixT<Float_t> as(SEXP m)
75 {
76 NumericMatrix mat =::Rcpp::as<NumericMatrix>(m);
77 std::vector<Float_t> dat = Rcpp::as<std::vector<Float_t>>(mat);
78 return TMatrixT<Float_t>(mat.rows(), mat.cols(), &dat[0], "F");
79 }
80
81//TRObject
82 template<> SEXP wrap(const ROOT::R::TRObject &obj)
83 {
84 return obj.fObj;
85 }
86
87 template<> ROOT::R::TRObject as(SEXP obj)
88 {
89 return ROOT::R::TRObject(obj);
90 }
91//TRDataFrame
92 template<> SEXP wrap(const ROOT::R::TRDataFrame &obj)
93 {
94 return obj.df;
95 }
96
97 template<> ROOT::R::TRDataFrame as(SEXP obj)
98 {
99 return ROOT::R::TRDataFrame(Rcpp::as<Rcpp::DataFrame>(obj));
100 }
101
102//TRFunctionImport
103 template<> SEXP wrap(const ROOT::R::TRFunctionImport &obj)
104 {
105 return *obj.f;
106 }
107
108 template<> ROOT::R::TRFunctionImport as(SEXP obj)
109 {
110 return ROOT::R::TRFunctionImport(Rcpp::as<Rcpp::Function>(obj));
111 }
112
113}
114namespace ROOT {
115 namespace R {
116 VARIABLE_IS_NOT_USED SEXP ModuleSymRef = NULL;
117 }
118}
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
This is a class to create DataFrames from ROOT to R.
Rcpp::DataFrame df
This is a class to pass functions from ROOT to R.
This is a class to get ROOT's objects from R's objects.
Definition TRObject.h:70
Rcpp::RObject fObj
Definition TRObject.h:73
TMatrixT.
Definition TMatrixT.h:39
TVectorT.
Definition TVectorT.h:27
const Rcpp::internal::NamedPlaceHolder & Label
VARIABLE_IS_NOT_USED SEXP ModuleSymRef
Definition RExports.cxx:116
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
This is a class to support deprecated method to pass function to R's Environment, based in Rcpp::Inte...
Definition RExports.h:79
SEXP wrap(const TString &s)
Definition RExports.h:82
TString as(SEXP s)
Definition RExports.h:86
TMarker m
Definition textangle.C:8