FastAD is a header-only library which only depends on Eigen3. That makes for a pretty straightforward application for Rcpp and friends.
First, rely on the RcppEigen.package.skeleton()
function to create the barebones RcppEigen-using package.
Second, we copy the FastAD library into inst/include
. We add a PKG_CPPFLAGS
variable in src/Makevars
to let R know to source it from there. That is all the compiler needs with a header-only library. (Edit: We also set CXX_STD=CXX17
unless one has a new enough compiler or R (currently: r-devel) which already default to C++17.)
Third, we create a simple example in src/
based on an example in FastAD. We picked the Black-Scholes example.
Fourth, minor cleanups like removing the hello*
stanza files.
That is pretty much it. In its embryonic form the package is now here on GitHub. An example is
> library(RcppFastAD)
> blackScholesExamples()
56.5136
0.773818
51.4109
-0.226182
>