Thanks a lot, sorry for my question, it was indeed here in front of me ... R.
----- Mail original ----- De: "Dirk Eddelbuettel" <[email protected]> À: "Dirk Eddelbuettel" <[email protected]> Cc: "Robin Girard" <[email protected]>, "rcpp-devel" <[email protected]> Envoyé: Jeudi 10 Juillet 2014 19:35:52 Objet: Re: [Rcpp-devel] Rational number and the BH package Robin, Here is a quick example for using the BH package from CRAN to get rational numbers: R> sourceCpp("/tmp/ratEx.cpp") R> invisible(quicktest()) Half is 1/2 Sum of two halves is 1/1 R> where the code in /tmp/ratEx.cpp follows below. I enable C++11 merely for convenience as R (and g++) otherwise complain about 'long long'. Should your compile not like or support C++11, just remove the line with the cpp11 plugin. Dirk #include <Rcpp.h> // [[Rcpp::depends(BH)]] #include <boost/rational.hpp> // not needed but suppress 'long long' warnings from Boost // [[Rcpp::plugins(cpp11)]] // [[Rcpp::export]] bool quicktest() { boost::rational<int> half(1,2); Rcpp::Rcout << "Half is " << half << std::endl; Rcpp::Rcout << "Sum of two halves is " << half + half << std::endl; return true; } /*** R invisible(quicktest()) */ -- http://dirk.eddelbuettel.com | @eddelbuettel | [email protected] _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
