twolodzko / extraDistr

Additional univariate and multivariate distributions
51 stars 11 forks source link

Feature request: making extraDistr functions callable from C++ #23

Closed fintzij closed 4 years ago

fintzij commented 4 years ago

Hello,

Would it be possible to export the functions in the extraDistr library to make them callable from C++?

Really love this package!

Thanks, Jon

twolodzko commented 4 years ago

Hi,

This package heavily depends on R internals and Rcpp, so if you wanted to use it with C++ code you would need to have them as dependencies. In many cases you could probably use the code, but replace some of the functions with C++ replacements (e.g. uniform random number generator, some math functions etc.). It was never meant as a standalone C++ library.

Tim

fintzij commented 4 years ago

Thanks for the quick response Tim! Actually, I was hoping to use some of the distributions in C++ code within an R package I'm working on, so the dependencies are a bit of a non-issue in my case. I think it's relatively straightforward to export the header, just a matter of specifying an additional interface at the head of each C++ script (see here: https://r-pkgs.org/src.html#cpp, as well as an example here: https://github.com/fintzij/ECctmc/blob/master/src/simulation_functions.cpp).

I've borrowed the code for one of the distributions I needed as a stopgap, but would generally prefer to link against extraDistr for various reliability reasons and to minimize duplication of effort. Totally understand if you think this is an edge case and maybe not worth the effort though.

Thanks again!! Jon

twolodzko commented 4 years ago

@fintzij I'd be happy to accept a PR with the changes, but currently I'm only maintaining this package and not considering any larger enhancements, so it is unlikely that I would do this by myself in near future.

fintzij commented 4 years ago

Thanks!

twolodzko commented 4 years ago

@fintzij I wanted to upload it on CRAN but I got this...

Uploading package & comments Error: Submission failed: The submission team is on vacation from Aug 14, 2020 to Aug 24, 2020. During this time the submission of packages is not possible. Sorry for any inconvenience.

fintzij commented 4 years ago

No worries, even heroes need vacation! I can keep working with my locally forked version for a while, thanks for merging the PR.

twolodzko commented 4 years ago

@fintzij FYI: it's on CRAN.