Search code examples
c++rcppgmp

Returning GMP class with Rcpp


I'm developing an R library with Rcpp. It wraps a C++ function that uses the GMP library for multiprecision operations. It works fine, the linking it's right and if the R function returns nothing (void), I have check the operation it is done perfectly. Now, my question is: is it possible to return a mpf_class or mpz_class from the C++ function, and bind it in a Rmpfr and bigz object on the R side? Hoping this would not an already asked question


Solution

  • Well, finally I've done it returning from c++ a Rcpp::StringVector, and in the RcppExports.R I'm getting the list returned in the .Call method and converting the items with the gmp::as.bigz() function. It works, the pain is that I've to be careful when executing Rcpp::compileAtributtes() because the file is overwritten.

    I've tried defining the wrap function, but it doesn´t work as I expected.