/************************************************************************* * Copyright (C) 2013-2014, Omar Andres Zapata Mesa * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #include #include #include #include #include Rcpp::internal::NamedPlaceHolder ROOT::R::Label; 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; } }