twolodzko / extraDistr

Additional univariate and multivariate distributions
49 stars 11 forks source link

export distributions to C++ via extraDistr header #24

Closed fintzij closed 4 years ago

fintzij commented 4 years ago

Added C++ interface to distributions and generated C++ header file to allow for packages with C++ code to link to extraDistr

twolodzko commented 4 years ago

That was fast!

fintzij commented 4 years ago

Sure thing, just pushed the updates. Minimal working example below. The way this would get used in an R package is that you would link to extraDistr in the Description file and then put #include <extraDistr.h> at the top of the C++ code where you want to use the distributions in extraDistr.

`library(Rcpp)

cppFunction( "Rcpp::NumericVector rbetbinom(int n, Rcpp::NumericVector size, Rcpp::NumericVector alpha, Rcpp::NumericVector beta) { return extraDistr::cpp_rbbinom(n, size, alpha, beta); }", depends = "extraDistr")

rbetbinom(10, 100.0, 5.4, 2.3) `

fintzij commented 4 years ago

Not sure why one of the tests is failing. I only updated the date and version in the Description and the NEWS files. All tests pass on my machine as well. I suspect the failing p-r-random-test is unrelated to this PR.

OK: 3198 Failed: 0 Warnings: 0 Skipped: 9

twolodzko commented 4 years ago

I've re-run the tests and they pass. Maybe mention in NEWS, or other place that it's your contribution?

I'll look at it tomorrow and if possible merge and post to CRAN.

fintzij commented 4 years ago

Sounds good, thank you!!